<?php


/**
 * Base class that represents a row from the 'users' table.
 *
 *
 *
 * @package    propel.generator.rcp.om
 */
abstract class RcpBaseUsers extends BaseObject implements Persistent
{
    /**
     * Peer class name
     */
    const PEER = 'RcpUsersPeer';

    /**
     * The Peer class.
     * Instance provides a convenient way of calling static methods on a class
     * that calling code may not be able to identify.
     * @var        RcpUsersPeer
     */
    protected static $peer;

    /**
     * The flag var to prevent infinit loop in deep copy
     * @var       boolean
     */
    protected $startCopy = false;

    /**
     * The value for the id field.
     * @var        int
     */
    protected $id;

    /**
     * The value for the ext_id field.
     * @var        string
     */
    protected $ext_id;

    /**
     * The value for the position_id field.
     * @var        int
     */
    protected $position_id;

    /**
     * The value for the unit_id field.
     * @var        int
     */
    protected $unit_id;

    /**
     * The value for the fname field.
     * @var        string
     */
    protected $fname;

    /**
     * The value for the lname field.
     * @var        string
     */
    protected $lname;

    /**
     * The value for the email field.
     * @var        string
     */
    protected $email;

    /**
     * The value for the optional_email field.
     * @var        string
     */
    protected $optional_email;

    /**
     * The value for the password field.
     * @var        string
     */
    protected $password;

    /**
     * The value for the ad_login_1 field.
     * @var        string
     */
    protected $ad_login_1;

    /**
     * The value for the ad_login_2 field.
     * @var        string
     */
    protected $ad_login_2;

    /**
     * The value for the ad_login_3 field.
     * @var        string
     */
    protected $ad_login_3;

    /**
     * The value for the is_superior field.
     * Note: this column has a database default value of: false
     * @var        boolean
     */
    protected $is_superior;

    /**
     * The value for the deleted field.
     * @var        string
     */
    protected $deleted;

    /**
     * The value for the active field.
     * Note: this column has a database default value of: true
     * @var        boolean
     */
    protected $active;

    /**
     * The value for the last_modified field.
     * @var        string
     */
    protected $last_modified;

    /**
     * The value for the created field.
     * Note: this column has a database default value of: '2014-07-17 09:55:27'
     * @var        string
     */
    protected $created;

    /**
     * @var        Units
     */
    protected $aUnits;

    /**
     * @var        Positions
     */
    protected $aPositions;

    /**
     * @var        PropelObjectCollection|RcpLecturePresences[] Collection to store aggregation of RcpLecturePresences objects.
     */
    protected $collLecturePresencess;
    protected $collLecturePresencessPartial;

    /**
     * @var        PropelObjectCollection|RcpAuthHistory[] Collection to store aggregation of RcpAuthHistory objects.
     */
    protected $collAuthHistorys;
    protected $collAuthHistorysPartial;

    /**
     * @var        PropelObjectCollection|RcpCalendarEvents[] Collection to store aggregation of RcpCalendarEvents objects.
     */
    protected $collCalendarEventss;
    protected $collCalendarEventssPartial;

    /**
     * @var        PropelObjectCollection|RcpEventOrders[] Collection to store aggregation of RcpEventOrders objects.
     */
    protected $collEventOrderss;
    protected $collEventOrderssPartial;

    /**
     * @var        PropelObjectCollection|RcpLectures[] Collection to store aggregation of RcpLectures objects.
     */
    protected $collLecturess;
    protected $collLecturessPartial;

    /**
     * @var        PropelObjectCollection|RcpUserHasLecture[] Collection to store aggregation of RcpUserHasLecture objects.
     */
    protected $collUserHasLectures;
    protected $collUserHasLecturesPartial;

    /**
     * @var        PropelObjectCollection|RcpUserRoles[] Collection to store aggregation of RcpUserRoles objects.
     */
    protected $collUserRoless;
    protected $collUserRolessPartial;

    /**
     * @var        PropelObjectCollection|RcpSystemLogs[] Collection to store aggregation of RcpSystemLogs objects.
     */
    protected $collSystemLogss;
    protected $collSystemLogssPartial;

    /**
     * @var        PropelObjectCollection|RcpUserCalendars[] Collection to store aggregation of RcpUserCalendars objects.
     */
    protected $collUserCalendarss;
    protected $collUserCalendarssPartial;

    /**
     * @var        PropelObjectCollection|RcpViewCalendarEvents[] Collection to store aggregation of RcpViewCalendarEvents objects.
     */
    protected $collViewCalendarEventss;
    protected $collViewCalendarEventssPartial;

    /**
     * Flag to prevent endless save loop, if this object is referenced
     * by another object which falls in this transaction.
     * @var        boolean
     */
    protected $alreadyInSave = false;

    /**
     * Flag to prevent endless validation loop, if this object is referenced
     * by another object which falls in this transaction.
     * @var        boolean
     */
    protected $alreadyInValidation = false;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $lecturePresencessScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $authHistorysScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $calendarEventssScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $eventOrderssScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $lecturessScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $userHasLecturesScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $userRolessScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $systemLogssScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $userCalendarssScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $viewCalendarEventssScheduledForDeletion = null;

    /**
     * Applies default values to this object.
     * This method should be called from the object's constructor (or
     * equivalent initialization method).
     * @see        __construct()
     */
    public function applyDefaultValues()
    {
        $this->is_superior = false;
        $this->active = true;
        $this->created = '2014-07-17 09:55:27';
    }

    /**
     * Initializes internal state of RcpBaseUsers object.
     * @see        applyDefaults()
     */
    public function __construct()
    {
        parent::__construct();
        $this->applyDefaultValues();
    }

    /**
     * Get the [id] column value.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Get the [ext_id] column value.
     *
     * @return string
     */
    public function getExtId()
    {
        return $this->ext_id;
    }

    /**
     * Get the [position_id] column value.
     *
     * @return int
     */
    public function getPositionId()
    {
        return $this->position_id;
    }

    /**
     * Get the [unit_id] column value.
     *
     * @return int
     */
    public function getUnitId()
    {
        return $this->unit_id;
    }

    /**
     * Get the [fname] column value.
     *
     * @return string
     */
    public function getFname()
    {
        return $this->fname;
    }

    /**
     * Get the [lname] column value.
     *
     * @return string
     */
    public function getLname()
    {
        return $this->lname;
    }

    /**
     * Get the [email] column value.
     *
     * @return string
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * Get the [optional_email] column value.
     *
     * @return string
     */
    public function getOptionalEmail()
    {
        return $this->optional_email;
    }

    /**
     * Get the [password] column value.
     *
     * @return string
     */
    public function getPassword()
    {
        return $this->password;
    }

    /**
     * Get the [ad_login_1] column value.
     *
     * @return string
     */
    public function getAdLogin1()
    {
        return $this->ad_login_1;
    }

    /**
     * Get the [ad_login_2] column value.
     *
     * @return string
     */
    public function getAdLogin2()
    {
        return $this->ad_login_2;
    }

    /**
     * Get the [ad_login_3] column value.
     *
     * @return string
     */
    public function getAdLogin3()
    {
        return $this->ad_login_3;
    }

    /**
     * Get the [is_superior] column value.
     *
     * @return boolean
     */
    public function getIsSuperior()
    {
        return $this->is_superior;
    }

    /**
     * Get the [optionally formatted] temporal [deleted] column value.
     *
     *
     * @param string $format The date/time format string (either date()-style or strftime()-style).
     *				 If format is null, then the raw DateTime object will be returned.
     * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
     * @throws PropelException - if unable to parse/validate the date/time value.
     */
    public function getDeleted($format = 'Y-m-d H:i:s')
    {
        if ($this->deleted === null) {
            return null;
        }


        try {
            $dt = new DateTime($this->deleted);
        } catch (Exception $x) {
            throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->deleted, true), $x);
        }

        if ($format === null) {
            // Because propel.useDateTimeClass is true, we return a DateTime object.
            return $dt;
        } elseif (strpos($format, '%') !== false) {
            return strftime($format, $dt->format('U'));
        } else {
            return $dt->format($format);
        }
    }

    /**
     * Get the [active] column value.
     *
     * @return boolean
     */
    public function getActive()
    {
        return $this->active;
    }

    /**
     * Get the [optionally formatted] temporal [last_modified] column value.
     *
     *
     * @param string $format The date/time format string (either date()-style or strftime()-style).
     *				 If format is null, then the raw DateTime object will be returned.
     * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
     * @throws PropelException - if unable to parse/validate the date/time value.
     */
    public function getLastModified($format = 'Y-m-d H:i:s')
    {
        if ($this->last_modified === null) {
            return null;
        }


        try {
            $dt = new DateTime($this->last_modified);
        } catch (Exception $x) {
            throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_modified, true), $x);
        }

        if ($format === null) {
            // Because propel.useDateTimeClass is true, we return a DateTime object.
            return $dt;
        } elseif (strpos($format, '%') !== false) {
            return strftime($format, $dt->format('U'));
        } else {
            return $dt->format($format);
        }
    }

    /**
     * Get the [optionally formatted] temporal [created] column value.
     *
     *
     * @param string $format The date/time format string (either date()-style or strftime()-style).
     *				 If format is null, then the raw DateTime object will be returned.
     * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
     * @throws PropelException - if unable to parse/validate the date/time value.
     */
    public function getCreated($format = 'Y-m-d H:i:s')
    {
        if ($this->created === null) {
            return null;
        }


        try {
            $dt = new DateTime($this->created);
        } catch (Exception $x) {
            throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created, true), $x);
        }

        if ($format === null) {
            // Because propel.useDateTimeClass is true, we return a DateTime object.
            return $dt;
        } elseif (strpos($format, '%') !== false) {
            return strftime($format, $dt->format('U'));
        } else {
            return $dt->format($format);
        }
    }

    /**
     * Set the value of [id] column.
     *
     * @param int $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->id !== $v) {
            $this->id = $v;
            $this->modifiedColumns[] = RcpUsersPeer::ID;
        }


        return $this;
    } // setId()

    /**
     * Set the value of [ext_id] column.
     *
     * @param string $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setExtId($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->ext_id !== $v) {
            $this->ext_id = $v;
            $this->modifiedColumns[] = RcpUsersPeer::EXT_ID;
        }


        return $this;
    } // setExtId()

    /**
     * Set the value of [position_id] column.
     *
     * @param int $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setPositionId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->position_id !== $v) {
            $this->position_id = $v;
            $this->modifiedColumns[] = RcpUsersPeer::POSITION_ID;
        }

        if ($this->aPositions !== null && $this->aPositions->getId() !== $v) {
            $this->aPositions = null;
        }


        return $this;
    } // setPositionId()

    /**
     * Set the value of [unit_id] column.
     *
     * @param int $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setUnitId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->unit_id !== $v) {
            $this->unit_id = $v;
            $this->modifiedColumns[] = RcpUsersPeer::UNIT_ID;
        }

        if ($this->aUnits !== null && $this->aUnits->getId() !== $v) {
            $this->aUnits = null;
        }


        return $this;
    } // setUnitId()

    /**
     * Set the value of [fname] column.
     *
     * @param string $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setFname($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->fname !== $v) {
            $this->fname = $v;
            $this->modifiedColumns[] = RcpUsersPeer::FNAME;
        }


        return $this;
    } // setFname()

    /**
     * Set the value of [lname] column.
     *
     * @param string $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setLname($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->lname !== $v) {
            $this->lname = $v;
            $this->modifiedColumns[] = RcpUsersPeer::LNAME;
        }


        return $this;
    } // setLname()

    /**
     * Set the value of [email] column.
     *
     * @param string $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setEmail($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->email !== $v) {
            $this->email = $v;
            $this->modifiedColumns[] = RcpUsersPeer::EMAIL;
        }


        return $this;
    } // setEmail()

    /**
     * Set the value of [optional_email] column.
     *
     * @param string $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setOptionalEmail($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->optional_email !== $v) {
            $this->optional_email = $v;
            $this->modifiedColumns[] = RcpUsersPeer::OPTIONAL_EMAIL;
        }


        return $this;
    } // setOptionalEmail()

    /**
     * Set the value of [password] column.
     *
     * @param string $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setPassword($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->password !== $v) {
            $this->password = $v;
            $this->modifiedColumns[] = RcpUsersPeer::PASSWORD;
        }


        return $this;
    } // setPassword()

    /**
     * Set the value of [ad_login_1] column.
     *
     * @param string $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setAdLogin1($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->ad_login_1 !== $v) {
            $this->ad_login_1 = $v;
            $this->modifiedColumns[] = RcpUsersPeer::AD_LOGIN_1;
        }


        return $this;
    } // setAdLogin1()

    /**
     * Set the value of [ad_login_2] column.
     *
     * @param string $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setAdLogin2($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->ad_login_2 !== $v) {
            $this->ad_login_2 = $v;
            $this->modifiedColumns[] = RcpUsersPeer::AD_LOGIN_2;
        }


        return $this;
    } // setAdLogin2()

    /**
     * Set the value of [ad_login_3] column.
     *
     * @param string $v new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setAdLogin3($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->ad_login_3 !== $v) {
            $this->ad_login_3 = $v;
            $this->modifiedColumns[] = RcpUsersPeer::AD_LOGIN_3;
        }


        return $this;
    } // setAdLogin3()

    /**
     * Sets the value of the [is_superior] column.
     * Non-boolean arguments are converted using the following rules:
     *   * 1, '1', 'true',  'on',  and 'yes' are converted to boolean true
     *   * 0, '0', 'false', 'off', and 'no'  are converted to boolean false
     * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
     *
     * @param boolean|integer|string $v The new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setIsSuperior($v)
    {
        if ($v !== null) {
            if (is_string($v)) {
                $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
            } else {
                $v = (boolean) $v;
            }
        }

        if ($this->is_superior !== $v) {
            $this->is_superior = $v;
            $this->modifiedColumns[] = RcpUsersPeer::IS_SUPERIOR;
        }


        return $this;
    } // setIsSuperior()

    /**
     * Sets the value of [deleted] column to a normalized version of the date/time value specified.
     *
     * @param mixed $v string, integer (timestamp), or DateTime value.
     *               Empty strings are treated as null.
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setDeleted($v)
    {
        $dt = PropelDateTime::newInstance($v, null, 'DateTime');
        if ($this->deleted !== null || $dt !== null) {
            $currentDateAsString = ($this->deleted !== null && $tmpDt = new DateTime($this->deleted)) ? $tmpDt->format('Y-m-d H:i:s') : null;
            $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
            if ($currentDateAsString !== $newDateAsString) {
                $this->deleted = $newDateAsString;
                $this->modifiedColumns[] = RcpUsersPeer::DELETED;
            }
        } // if either are not null


        return $this;
    } // setDeleted()

    /**
     * Sets the value of the [active] column.
     * Non-boolean arguments are converted using the following rules:
     *   * 1, '1', 'true',  'on',  and 'yes' are converted to boolean true
     *   * 0, '0', 'false', 'off', and 'no'  are converted to boolean false
     * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
     *
     * @param boolean|integer|string $v The new value
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setActive($v)
    {
        if ($v !== null) {
            if (is_string($v)) {
                $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
            } else {
                $v = (boolean) $v;
            }
        }

        if ($this->active !== $v) {
            $this->active = $v;
            $this->modifiedColumns[] = RcpUsersPeer::ACTIVE;
        }


        return $this;
    } // setActive()

    /**
     * Sets the value of [last_modified] column to a normalized version of the date/time value specified.
     *
     * @param mixed $v string, integer (timestamp), or DateTime value.
     *               Empty strings are treated as null.
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setLastModified($v)
    {
        $dt = PropelDateTime::newInstance($v, null, 'DateTime');
        if ($this->last_modified !== null || $dt !== null) {
            $currentDateAsString = ($this->last_modified !== null && $tmpDt = new DateTime($this->last_modified)) ? $tmpDt->format('Y-m-d H:i:s') : null;
            $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
            if ($currentDateAsString !== $newDateAsString) {
                $this->last_modified = $newDateAsString;
                $this->modifiedColumns[] = RcpUsersPeer::LAST_MODIFIED;
            }
        } // if either are not null


        return $this;
    } // setLastModified()

    /**
     * Sets the value of [created] column to a normalized version of the date/time value specified.
     *
     * @param mixed $v string, integer (timestamp), or DateTime value.
     *               Empty strings are treated as null.
     * @return RcpUsers The current object (for fluent API support)
     */
    public function setCreated($v)
    {
        $dt = PropelDateTime::newInstance($v, null, 'DateTime');
        if ($this->created !== null || $dt !== null) {
            $currentDateAsString = ($this->created !== null && $tmpDt = new DateTime($this->created)) ? $tmpDt->format('Y-m-d H:i:s') : null;
            $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
            if ( ($currentDateAsString !== $newDateAsString) // normalized values don't match
                || ($dt->format('Y-m-d H:i:s') === '2014-07-17 09:55:27') // or the entered value matches the default
                 ) {
                $this->created = $newDateAsString;
                $this->modifiedColumns[] = RcpUsersPeer::CREATED;
            }
        } // if either are not null


        return $this;
    } // setCreated()

    /**
     * Indicates whether the columns in this object are only set to default values.
     *
     * This method can be used in conjunction with isModified() to indicate whether an object is both
     * modified _and_ has some values set which are non-default.
     *
     * @return boolean Whether the columns in this object are only been set with default values.
     */
    public function hasOnlyDefaultValues()
    {
            if ($this->is_superior !== false) {
                return false;
            }

            if ($this->active !== true) {
                return false;
            }

            if ($this->created !== '2014-07-17 09:55:27') {
                return false;
            }

        // otherwise, everything was equal, so return true
        return true;
    } // hasOnlyDefaultValues()

    /**
     * Hydrates (populates) the object variables with values from the database resultset.
     *
     * An offset (0-based "start column") is specified so that objects can be hydrated
     * with a subset of the columns in the resultset rows.  This is needed, for example,
     * for results of JOIN queries where the resultset row includes columns from two or
     * more tables.
     *
     * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
     * @param int $startcol 0-based offset column which indicates which restultset column to start with.
     * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
     * @return int             next starting column
     * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
     */
    public function hydrate($row, $startcol = 0, $rehydrate = false)
    {
        try {

            $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
            $this->ext_id = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
            $this->position_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
            $this->unit_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
            $this->fname = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
            $this->lname = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
            $this->email = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
            $this->optional_email = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
            $this->password = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
            $this->ad_login_1 = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
            $this->ad_login_2 = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
            $this->ad_login_3 = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null;
            $this->is_superior = ($row[$startcol + 12] !== null) ? (boolean) $row[$startcol + 12] : null;
            $this->deleted = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null;
            $this->active = ($row[$startcol + 14] !== null) ? (boolean) $row[$startcol + 14] : null;
            $this->last_modified = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null;
            $this->created = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null;
            $this->resetModified();

            $this->setNew(false);

            if ($rehydrate) {
                $this->ensureConsistency();
            }

            return $startcol + 17; // 17 = RcpUsersPeer::NUM_HYDRATE_COLUMNS.

        } catch (Exception $e) {
            throw new PropelException("Error populating RcpUsers object", $e);
        }
    }

    /**
     * Checks and repairs the internal consistency of the object.
     *
     * This method is executed after an already-instantiated object is re-hydrated
     * from the database.  It exists to check any foreign keys to make sure that
     * the objects related to the current object are correct based on foreign key.
     *
     * You can override this method in the stub class, but you should always invoke
     * the base method from the overridden method (i.e. parent::ensureConsistency()),
     * in case your model changes.
     *
     * @throws PropelException
     */
    public function ensureConsistency()
    {

        if ($this->aPositions !== null && $this->position_id !== $this->aPositions->getId()) {
            $this->aPositions = null;
        }
        if ($this->aUnits !== null && $this->unit_id !== $this->aUnits->getId()) {
            $this->aUnits = null;
        }
    } // ensureConsistency

    /**
     * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
     *
     * This will only work if the object has been saved and has a valid primary key set.
     *
     * @param boolean $deep (optional) Whether to also de-associated any related objects.
     * @param PropelPDO $con (optional) The PropelPDO connection to use.
     * @return void
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
     */
    public function reload($deep = false, PropelPDO $con = null)
    {
        if ($this->isDeleted()) {
            throw new PropelException("Cannot reload a deleted object.");
        }

        if ($this->isNew()) {
            throw new PropelException("Cannot reload an unsaved object.");
        }

        if ($con === null) {
            $con = Propel::getConnection(RcpUsersPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }

        // We don't need to alter the object instance pool; we're just modifying this instance
        // already in the pool.

        $stmt = RcpUsersPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
        $row = $stmt->fetch(PDO::FETCH_NUM);
        $stmt->closeCursor();
        if (!$row) {
            throw new PropelException('Cannot find matching row in the database to reload object values.');
        }
        $this->hydrate($row, 0, true); // rehydrate

        if ($deep) {  // also de-associate any related objects?

            $this->aUnits = null;
            $this->aPositions = null;
            $this->collLecturePresencess = null;

            $this->collAuthHistorys = null;

            $this->collCalendarEventss = null;

            $this->collEventOrderss = null;

            $this->collLecturess = null;

            $this->collUserHasLectures = null;

            $this->collUserRoless = null;

            $this->collSystemLogss = null;

            $this->collUserCalendarss = null;

            $this->collViewCalendarEventss = null;

        } // if (deep)
    }

    /**
     * Removes this object from datastore and sets delete attribute.
     *
     * @param PropelPDO $con
     * @return void
     * @throws PropelException
     * @throws Exception
     * @see        BaseObject::setDeleted()
     * @see        BaseObject::isDeleted()
     */
    public function delete(PropelPDO $con = null)
    {
        if ($this->isDeleted()) {
            throw new PropelException("This object has already been deleted.");
        }

        if ($con === null) {
            $con = Propel::getConnection(RcpUsersPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
        }

        $con->beginTransaction();
        try {
            $deleteQuery = RcpUsersQuery::create()
                ->filterByPrimaryKey($this->getPrimaryKey());
            $ret = $this->preDelete($con);
            if ($ret) {
                $deleteQuery->delete($con);
                $this->postDelete($con);
                $con->commit();
                $this->setDeleted(true);
            } else {
                $con->commit();
            }
        } catch (Exception $e) {
            $con->rollBack();
            throw $e;
        }
    }

    /**
     * Persists this object to the database.
     *
     * If the object is new, it inserts it; otherwise an update is performed.
     * All modified related objects will also be persisted in the doSave()
     * method.  This method wraps all precipitate database operations in a
     * single transaction.
     *
     * @param PropelPDO $con
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     * @throws PropelException
     * @throws Exception
     * @see        doSave()
     */
    public function save(PropelPDO $con = null)
    {
        if ($this->isDeleted()) {
            throw new PropelException("You cannot save an object that has been deleted.");
        }

        if ($con === null) {
            $con = Propel::getConnection(RcpUsersPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
        }

        $con->beginTransaction();
        $isInsert = $this->isNew();
        try {
            $ret = $this->preSave($con);
            if ($isInsert) {
                $ret = $ret && $this->preInsert($con);
            } else {
                $ret = $ret && $this->preUpdate($con);
            }
            if ($ret) {
                $affectedRows = $this->doSave($con);
                if ($isInsert) {
                    $this->postInsert($con);
                } else {
                    $this->postUpdate($con);
                }
                $this->postSave($con);
                RcpUsersPeer::addInstanceToPool($this);
            } else {
                $affectedRows = 0;
            }
            $con->commit();

            return $affectedRows;
        } catch (Exception $e) {
            $con->rollBack();
            throw $e;
        }
    }

    /**
     * Performs the work of inserting or updating the row in the database.
     *
     * If the object is new, it inserts it; otherwise an update is performed.
     * All related objects are also updated in this method.
     *
     * @param PropelPDO $con
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     * @throws PropelException
     * @see        save()
     */
    protected function doSave(PropelPDO $con)
    {
        $affectedRows = 0; // initialize var to track total num of affected rows
        if (!$this->alreadyInSave) {
            $this->alreadyInSave = true;

            // We call the save method on the following object(s) if they
            // were passed to this object by their coresponding set
            // method.  This object relates to these object(s) by a
            // foreign key reference.

            if ($this->aUnits !== null) {
                if ($this->aUnits->isModified() || $this->aUnits->isNew()) {
                    $affectedRows += $this->aUnits->save($con);
                }
                $this->setUnits($this->aUnits);
            }

            if ($this->aPositions !== null) {
                if ($this->aPositions->isModified() || $this->aPositions->isNew()) {
                    $affectedRows += $this->aPositions->save($con);
                }
                $this->setPositions($this->aPositions);
            }

            if ($this->isNew() || $this->isModified()) {
                // persist changes
                if ($this->isNew()) {
                    $this->doInsert($con);
                } else {
                    $this->doUpdate($con);
                }
                $affectedRows += 1;
                $this->resetModified();
            }

            if ($this->lecturePresencessScheduledForDeletion !== null) {
                if (!$this->lecturePresencessScheduledForDeletion->isEmpty()) {
                    RcpLecturePresencesQuery::create()
                        ->filterByPrimaryKeys($this->lecturePresencessScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->lecturePresencessScheduledForDeletion = null;
                }
            }

            if ($this->collLecturePresencess !== null) {
                foreach ($this->collLecturePresencess as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->authHistorysScheduledForDeletion !== null) {
                if (!$this->authHistorysScheduledForDeletion->isEmpty()) {
                    foreach ($this->authHistorysScheduledForDeletion as $authHistory) {
                        // need to save related object because we set the relation to null
                        $authHistory->save($con);
                    }
                    $this->authHistorysScheduledForDeletion = null;
                }
            }

            if ($this->collAuthHistorys !== null) {
                foreach ($this->collAuthHistorys as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->calendarEventssScheduledForDeletion !== null) {
                if (!$this->calendarEventssScheduledForDeletion->isEmpty()) {
                    RcpCalendarEventsQuery::create()
                        ->filterByPrimaryKeys($this->calendarEventssScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->calendarEventssScheduledForDeletion = null;
                }
            }

            if ($this->collCalendarEventss !== null) {
                foreach ($this->collCalendarEventss as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->eventOrderssScheduledForDeletion !== null) {
                if (!$this->eventOrderssScheduledForDeletion->isEmpty()) {
                    foreach ($this->eventOrderssScheduledForDeletion as $eventOrders) {
                        // need to save related object because we set the relation to null
                        $eventOrders->save($con);
                    }
                    $this->eventOrderssScheduledForDeletion = null;
                }
            }

            if ($this->collEventOrderss !== null) {
                foreach ($this->collEventOrderss as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->lecturessScheduledForDeletion !== null) {
                if (!$this->lecturessScheduledForDeletion->isEmpty()) {
                    RcpLecturesQuery::create()
                        ->filterByPrimaryKeys($this->lecturessScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->lecturessScheduledForDeletion = null;
                }
            }

            if ($this->collLecturess !== null) {
                foreach ($this->collLecturess as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->userHasLecturesScheduledForDeletion !== null) {
                if (!$this->userHasLecturesScheduledForDeletion->isEmpty()) {
                    RcpUserHasLectureQuery::create()
                        ->filterByPrimaryKeys($this->userHasLecturesScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->userHasLecturesScheduledForDeletion = null;
                }
            }

            if ($this->collUserHasLectures !== null) {
                foreach ($this->collUserHasLectures as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->userRolessScheduledForDeletion !== null) {
                if (!$this->userRolessScheduledForDeletion->isEmpty()) {
                    RcpUserRolesQuery::create()
                        ->filterByPrimaryKeys($this->userRolessScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->userRolessScheduledForDeletion = null;
                }
            }

            if ($this->collUserRoless !== null) {
                foreach ($this->collUserRoless as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->systemLogssScheduledForDeletion !== null) {
                if (!$this->systemLogssScheduledForDeletion->isEmpty()) {
                    foreach ($this->systemLogssScheduledForDeletion as $systemLogs) {
                        // need to save related object because we set the relation to null
                        $systemLogs->save($con);
                    }
                    $this->systemLogssScheduledForDeletion = null;
                }
            }

            if ($this->collSystemLogss !== null) {
                foreach ($this->collSystemLogss as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->userCalendarssScheduledForDeletion !== null) {
                if (!$this->userCalendarssScheduledForDeletion->isEmpty()) {
                    RcpUserCalendarsQuery::create()
                        ->filterByPrimaryKeys($this->userCalendarssScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->userCalendarssScheduledForDeletion = null;
                }
            }

            if ($this->collUserCalendarss !== null) {
                foreach ($this->collUserCalendarss as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->viewCalendarEventssScheduledForDeletion !== null) {
                if (!$this->viewCalendarEventssScheduledForDeletion->isEmpty()) {
                    RcpViewCalendarEventsQuery::create()
                        ->filterByPrimaryKeys($this->viewCalendarEventssScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->viewCalendarEventssScheduledForDeletion = null;
                }
            }

            if ($this->collViewCalendarEventss !== null) {
                foreach ($this->collViewCalendarEventss as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            $this->alreadyInSave = false;

        }

        return $affectedRows;
    } // doSave()

    /**
     * Insert the row in the database.
     *
     * @param PropelPDO $con
     *
     * @throws PropelException
     * @see        doSave()
     */
    protected function doInsert(PropelPDO $con)
    {
        $this->modifiedColumns[] = RcpUsersPeer::ID;
        $criteria = $this->buildCriteria();
        if ($criteria->keyContainsValue(RcpUsersPeer::ID) ) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . RcpUsersPeer::ID . ')');
        }
        // remove pkey col since this table uses auto-increment and passing a null value for it is not valid
        $criteria->remove(RcpUsersPeer::ID);
        $pk = BasePeer::doInsert($criteria, $con);
        $this->setId($pk);  //[IMV] update autoincrement primary key
        $this->setNew(false);
    }

    /**
     * Update the row in the database.
     *
     * @param PropelPDO $con
     *
     * @see        doSave()
     */
    protected function doUpdate(PropelPDO $con)
    {
        $selectCriteria = $this->buildPkeyCriteria();
        $valuesCriteria = $this->buildCriteria();
        BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
    }

    /**
     * Array of ValidationFailed objects.
     * @var        array ValidationFailed[]
     */
    protected $validationFailures = array();

    /**
     * Gets any ValidationFailed objects that resulted from last call to validate().
     *
     *
     * @return array ValidationFailed[]
     * @see        validate()
     */
    public function getValidationFailures()
    {
        return $this->validationFailures;
    }

    /**
     * Validates the objects modified field values and all objects related to this table.
     *
     * If $columns is either a column name or an array of column names
     * only those columns are validated.
     *
     * @param mixed $columns Column name or an array of column names.
     * @return boolean Whether all columns pass validation.
     * @see        doValidate()
     * @see        getValidationFailures()
     */
    public function validate($columns = null)
    {
        $res = $this->doValidate($columns);
        if ($res === true) {
            $this->validationFailures = array();

            return true;
        } else {
            $this->validationFailures = $res;

            return false;
        }
    }

    /**
     * This function performs the validation work for complex object models.
     *
     * In addition to checking the current object, all related objects will
     * also be validated.  If all pass then <code>true</code> is returned; otherwise
     * an aggreagated array of ValidationFailed objects will be returned.
     *
     * @param array $columns Array of column names to validate.
     * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
     */
    protected function doValidate($columns = null)
    {
        if (!$this->alreadyInValidation) {
            $this->alreadyInValidation = true;
            $retval = null;

            $failureMap = array();


            // We call the validate method on the following object(s) if they
            // were passed to this object by their coresponding set
            // method.  This object relates to these object(s) by a
            // foreign key reference.

            if ($this->aUnits !== null) {
                if (!$this->aUnits->validate($columns)) {
                    $failureMap = array_merge($failureMap, $this->aUnits->getValidationFailures());
                }
            }

            if ($this->aPositions !== null) {
                if (!$this->aPositions->validate($columns)) {
                    $failureMap = array_merge($failureMap, $this->aPositions->getValidationFailures());
                }
            }


            if (($retval = RcpUsersPeer::doValidate($this, $columns)) !== true) {
                $failureMap = array_merge($failureMap, $retval);
            }


                if ($this->collLecturePresencess !== null) {
                    foreach ($this->collLecturePresencess as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collAuthHistorys !== null) {
                    foreach ($this->collAuthHistorys as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collCalendarEventss !== null) {
                    foreach ($this->collCalendarEventss as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collEventOrderss !== null) {
                    foreach ($this->collEventOrderss as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collLecturess !== null) {
                    foreach ($this->collLecturess as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collUserHasLectures !== null) {
                    foreach ($this->collUserHasLectures as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collUserRoless !== null) {
                    foreach ($this->collUserRoless as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collSystemLogss !== null) {
                    foreach ($this->collSystemLogss as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collUserCalendarss !== null) {
                    foreach ($this->collUserCalendarss as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collViewCalendarEventss !== null) {
                    foreach ($this->collViewCalendarEventss as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }


            $this->alreadyInValidation = false;
        }

        return (!empty($failureMap) ? $failureMap : true);
    }

    /**
     * Retrieves a field from the object by name passed in as a string.
     *
     * @param string $name name
     * @param string $type The type of fieldname the $name is of:
     *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     *               Defaults to BasePeer::TYPE_PHPNAME
     * @return mixed Value of field.
     */
    public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
    {
        $pos = RcpUsersPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
        $field = $this->getByPosition($pos);

        return $field;
    }

    /**
     * Retrieves a field from the object by Position as specified in the xml schema.
     * Zero-based.
     *
     * @param int $pos position in xml schema
     * @return mixed Value of field at $pos
     */
    public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getExtId();
                break;
            case 2:
                return $this->getPositionId();
                break;
            case 3:
                return $this->getUnitId();
                break;
            case 4:
                return $this->getFname();
                break;
            case 5:
                return $this->getLname();
                break;
            case 6:
                return $this->getEmail();
                break;
            case 7:
                return $this->getOptionalEmail();
                break;
            case 8:
                return $this->getPassword();
                break;
            case 9:
                return $this->getAdLogin1();
                break;
            case 10:
                return $this->getAdLogin2();
                break;
            case 11:
                return $this->getAdLogin3();
                break;
            case 12:
                return $this->getIsSuperior();
                break;
            case 13:
                return $this->getDeleted();
                break;
            case 14:
                return $this->getActive();
                break;
            case 15:
                return $this->getLastModified();
                break;
            case 16:
                return $this->getCreated();
                break;
            default:
                return null;
                break;
        } // switch()
    }

    /**
     * Exports the object as an array.
     *
     * You can specify the key type of the array by passing one of the class
     * type constants.
     *
     * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
     *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     *                    Defaults to BasePeer::TYPE_PHPNAME.
     * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
     * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
     * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
     *
     * @return array an associative array containing the field names (as keys) and field values
     */
    public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
    {
        if (isset($alreadyDumpedObjects['RcpUsers'][$this->getPrimaryKey()])) {
            return '*RECURSION*';
        }
        $alreadyDumpedObjects['RcpUsers'][$this->getPrimaryKey()] = true;
        $keys = RcpUsersPeer::getFieldNames($keyType);
        $result = array(
            $keys[0] => $this->getId(),
            $keys[1] => $this->getExtId(),
            $keys[2] => $this->getPositionId(),
            $keys[3] => $this->getUnitId(),
            $keys[4] => $this->getFname(),
            $keys[5] => $this->getLname(),
            $keys[6] => $this->getEmail(),
            $keys[7] => $this->getOptionalEmail(),
            $keys[8] => $this->getPassword(),
            $keys[9] => $this->getAdLogin1(),
            $keys[10] => $this->getAdLogin2(),
            $keys[11] => $this->getAdLogin3(),
            $keys[12] => $this->getIsSuperior(),
            $keys[13] => $this->getDeleted(),
            $keys[14] => $this->getActive(),
            $keys[15] => $this->getLastModified(),
            $keys[16] => $this->getCreated(),
        );
        if ($includeForeignObjects) {
            if (null !== $this->aUnits) {
                $result['Units'] = $this->aUnits->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
            }
            if (null !== $this->aPositions) {
                $result['Positions'] = $this->aPositions->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
            }
            if (null !== $this->collLecturePresencess) {
                $result['LecturePresencess'] = $this->collLecturePresencess->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collAuthHistorys) {
                $result['AuthHistorys'] = $this->collAuthHistorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collCalendarEventss) {
                $result['CalendarEventss'] = $this->collCalendarEventss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collEventOrderss) {
                $result['EventOrderss'] = $this->collEventOrderss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collLecturess) {
                $result['Lecturess'] = $this->collLecturess->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collUserHasLectures) {
                $result['UserHasLectures'] = $this->collUserHasLectures->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collUserRoless) {
                $result['UserRoless'] = $this->collUserRoless->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collSystemLogss) {
                $result['SystemLogss'] = $this->collSystemLogss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collUserCalendarss) {
                $result['UserCalendarss'] = $this->collUserCalendarss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collViewCalendarEventss) {
                $result['ViewCalendarEventss'] = $this->collViewCalendarEventss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
        }

        return $result;
    }

    /**
     * Sets a field from the object by name passed in as a string.
     *
     * @param string $name peer name
     * @param mixed $value field value
     * @param string $type The type of fieldname the $name is of:
     *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     *                     Defaults to BasePeer::TYPE_PHPNAME
     * @return void
     */
    public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
    {
        $pos = RcpUsersPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);

        $this->setByPosition($pos, $value);
    }

    /**
     * Sets a field from the object by Position as specified in the xml schema.
     * Zero-based.
     *
     * @param int $pos position in xml schema
     * @param mixed $value field value
     * @return void
     */
    public function setByPosition($pos, $value)
    {
        switch ($pos) {
            case 0:
                $this->setId($value);
                break;
            case 1:
                $this->setExtId($value);
                break;
            case 2:
                $this->setPositionId($value);
                break;
            case 3:
                $this->setUnitId($value);
                break;
            case 4:
                $this->setFname($value);
                break;
            case 5:
                $this->setLname($value);
                break;
            case 6:
                $this->setEmail($value);
                break;
            case 7:
                $this->setOptionalEmail($value);
                break;
            case 8:
                $this->setPassword($value);
                break;
            case 9:
                $this->setAdLogin1($value);
                break;
            case 10:
                $this->setAdLogin2($value);
                break;
            case 11:
                $this->setAdLogin3($value);
                break;
            case 12:
                $this->setIsSuperior($value);
                break;
            case 13:
                $this->setDeleted($value);
                break;
            case 14:
                $this->setActive($value);
                break;
            case 15:
                $this->setLastModified($value);
                break;
            case 16:
                $this->setCreated($value);
                break;
        } // switch()
    }

    /**
     * Populates the object using an array.
     *
     * This is particularly useful when populating an object from one of the
     * request arrays (e.g. $_POST).  This method goes through the column
     * names, checking to see whether a matching key exists in populated
     * array. If so the setByName() method is called for that column.
     *
     * You can specify the key type of the array by additionally passing one
     * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
     * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     * The default key type is the column's BasePeer::TYPE_PHPNAME
     *
     * @param array  $arr     An array to populate the object from.
     * @param string $keyType The type of keys the array uses.
     * @return void
     */
    public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
    {
        $keys = RcpUsersPeer::getFieldNames($keyType);

        if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
        if (array_key_exists($keys[1], $arr)) $this->setExtId($arr[$keys[1]]);
        if (array_key_exists($keys[2], $arr)) $this->setPositionId($arr[$keys[2]]);
        if (array_key_exists($keys[3], $arr)) $this->setUnitId($arr[$keys[3]]);
        if (array_key_exists($keys[4], $arr)) $this->setFname($arr[$keys[4]]);
        if (array_key_exists($keys[5], $arr)) $this->setLname($arr[$keys[5]]);
        if (array_key_exists($keys[6], $arr)) $this->setEmail($arr[$keys[6]]);
        if (array_key_exists($keys[7], $arr)) $this->setOptionalEmail($arr[$keys[7]]);
        if (array_key_exists($keys[8], $arr)) $this->setPassword($arr[$keys[8]]);
        if (array_key_exists($keys[9], $arr)) $this->setAdLogin1($arr[$keys[9]]);
        if (array_key_exists($keys[10], $arr)) $this->setAdLogin2($arr[$keys[10]]);
        if (array_key_exists($keys[11], $arr)) $this->setAdLogin3($arr[$keys[11]]);
        if (array_key_exists($keys[12], $arr)) $this->setIsSuperior($arr[$keys[12]]);
        if (array_key_exists($keys[13], $arr)) $this->setDeleted($arr[$keys[13]]);
        if (array_key_exists($keys[14], $arr)) $this->setActive($arr[$keys[14]]);
        if (array_key_exists($keys[15], $arr)) $this->setLastModified($arr[$keys[15]]);
        if (array_key_exists($keys[16], $arr)) $this->setCreated($arr[$keys[16]]);
    }

    /**
     * Build a Criteria object containing the values of all modified columns in this object.
     *
     * @return Criteria The Criteria object containing all modified values.
     */
    public function buildCriteria()
    {
        $criteria = new Criteria(RcpUsersPeer::DATABASE_NAME);

        if ($this->isColumnModified(RcpUsersPeer::ID)) $criteria->add(RcpUsersPeer::ID, $this->id);
        if ($this->isColumnModified(RcpUsersPeer::EXT_ID)) $criteria->add(RcpUsersPeer::EXT_ID, $this->ext_id);
        if ($this->isColumnModified(RcpUsersPeer::POSITION_ID)) $criteria->add(RcpUsersPeer::POSITION_ID, $this->position_id);
        if ($this->isColumnModified(RcpUsersPeer::UNIT_ID)) $criteria->add(RcpUsersPeer::UNIT_ID, $this->unit_id);
        if ($this->isColumnModified(RcpUsersPeer::FNAME)) $criteria->add(RcpUsersPeer::FNAME, $this->fname);
        if ($this->isColumnModified(RcpUsersPeer::LNAME)) $criteria->add(RcpUsersPeer::LNAME, $this->lname);
        if ($this->isColumnModified(RcpUsersPeer::EMAIL)) $criteria->add(RcpUsersPeer::EMAIL, $this->email);
        if ($this->isColumnModified(RcpUsersPeer::OPTIONAL_EMAIL)) $criteria->add(RcpUsersPeer::OPTIONAL_EMAIL, $this->optional_email);
        if ($this->isColumnModified(RcpUsersPeer::PASSWORD)) $criteria->add(RcpUsersPeer::PASSWORD, $this->password);
        if ($this->isColumnModified(RcpUsersPeer::AD_LOGIN_1)) $criteria->add(RcpUsersPeer::AD_LOGIN_1, $this->ad_login_1);
        if ($this->isColumnModified(RcpUsersPeer::AD_LOGIN_2)) $criteria->add(RcpUsersPeer::AD_LOGIN_2, $this->ad_login_2);
        if ($this->isColumnModified(RcpUsersPeer::AD_LOGIN_3)) $criteria->add(RcpUsersPeer::AD_LOGIN_3, $this->ad_login_3);
        if ($this->isColumnModified(RcpUsersPeer::IS_SUPERIOR)) $criteria->add(RcpUsersPeer::IS_SUPERIOR, $this->is_superior);
        if ($this->isColumnModified(RcpUsersPeer::DELETED)) $criteria->add(RcpUsersPeer::DELETED, $this->deleted);
        if ($this->isColumnModified(RcpUsersPeer::ACTIVE)) $criteria->add(RcpUsersPeer::ACTIVE, $this->active);
        if ($this->isColumnModified(RcpUsersPeer::LAST_MODIFIED)) $criteria->add(RcpUsersPeer::LAST_MODIFIED, $this->last_modified);
        if ($this->isColumnModified(RcpUsersPeer::CREATED)) $criteria->add(RcpUsersPeer::CREATED, $this->created);

        return $criteria;
    }

    /**
     * Builds a Criteria object containing the primary key for this object.
     *
     * Unlike buildCriteria() this method includes the primary key values regardless
     * of whether or not they have been modified.
     *
     * @return Criteria The Criteria object containing value(s) for primary key(s).
     */
    public function buildPkeyCriteria()
    {
        $criteria = new Criteria(RcpUsersPeer::DATABASE_NAME);
        $criteria->add(RcpUsersPeer::ID, $this->id);

        return $criteria;
    }

    /**
     * Returns the primary key for this object (row).
     * @return int
     */
    public function getPrimaryKey()
    {
        return $this->getId();
    }

    /**
     * Generic method to set the primary key (id column).
     *
     * @param  int $key Primary key.
     * @return void
     */
    public function setPrimaryKey($key)
    {
        $this->setId($key);
    }

    /**
     * Returns true if the primary key for this object is null.
     * @return boolean
     */
    public function isPrimaryKeyNull()
    {

        return null === $this->getId();
    }

    /**
     * Sets contents of passed object to values from current object.
     *
     * If desired, this method can also make copies of all associated (fkey referrers)
     * objects.
     *
     * @param object $copyObj An object of RcpUsers (or compatible) type.
     * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
     * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
     * @throws PropelException
     */
    public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
    {
        $copyObj->setExtId($this->getExtId());
        $copyObj->setPositionId($this->getPositionId());
        $copyObj->setUnitId($this->getUnitId());
        $copyObj->setFname($this->getFname());
        $copyObj->setLname($this->getLname());
        $copyObj->setEmail($this->getEmail());
        $copyObj->setOptionalEmail($this->getOptionalEmail());
        $copyObj->setPassword($this->getPassword());
        $copyObj->setAdLogin1($this->getAdLogin1());
        $copyObj->setAdLogin2($this->getAdLogin2());
        $copyObj->setAdLogin3($this->getAdLogin3());
        $copyObj->setIsSuperior($this->getIsSuperior());
        $copyObj->setDeleted($this->getDeleted());
        $copyObj->setActive($this->getActive());
        $copyObj->setLastModified($this->getLastModified());
        $copyObj->setCreated($this->getCreated());

        if ($deepCopy && !$this->startCopy) {
            // important: temporarily setNew(false) because this affects the behavior of
            // the getter/setter methods for fkey referrer objects.
            $copyObj->setNew(false);
            // store object hash to prevent cycle
            $this->startCopy = true;

            foreach ($this->getLecturePresencess() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addLecturePresences($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getAuthHistorys() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addAuthHistory($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getCalendarEventss() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addCalendarEvents($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getEventOrderss() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addEventOrders($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getLecturess() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addLectures($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getUserHasLectures() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addUserHasLecture($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getUserRoless() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addUserRoles($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getSystemLogss() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addSystemLogs($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getUserCalendarss() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addUserCalendars($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getViewCalendarEventss() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addViewCalendarEvents($relObj->copy($deepCopy));
                }
            }

            //unflag object copy
            $this->startCopy = false;
        } // if ($deepCopy)

        if ($makeNew) {
            $copyObj->setNew(true);
            $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
        }
    }

    /**
     * Makes a copy of this object that will be inserted as a new row in table when saved.
     * It creates a new object filling in the simple attributes, but skipping any primary
     * keys that are defined for the table.
     *
     * If desired, this method can also make copies of all associated (fkey referrers)
     * objects.
     *
     * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
     * @return RcpUsers Clone of current object.
     * @throws PropelException
     */
    public function copy($deepCopy = false)
    {
        // we use get_class(), because this might be a subclass
        $clazz = get_class($this);
        $copyObj = new $clazz();
        $this->copyInto($copyObj, $deepCopy);

        return $copyObj;
    }

    /**
     * Returns a peer instance associated with this om.
     *
     * Since Peer classes are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     *
     * @return RcpUsersPeer
     */
    public function getPeer()
    {
        if (self::$peer === null) {
            self::$peer = new RcpUsersPeer();
        }

        return self::$peer;
    }

    /**
     * Declares an association between this object and a RcpUnits object.
     *
     * @param             RcpUnits $v
     * @return RcpUsers The current object (for fluent API support)
     * @throws PropelException
     */
    public function setUnits(RcpUnits $v = null)
    {
        if ($v === null) {
            $this->setUnitId(NULL);
        } else {
            $this->setUnitId($v->getId());
        }

        $this->aUnits = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the RcpUnits object, it will not be re-added.
        if ($v !== null) {
            $v->addUsers($this);
        }


        return $this;
    }


    /**
     * Get the associated RcpUnits object
     *
     * @param PropelPDO $con Optional Connection object.
     * @return RcpUnits The associated RcpUnits object.
     * @throws PropelException
     */
    public function getUnits(PropelPDO $con = null)
    {
        if ($this->aUnits === null && ($this->unit_id !== null)) {
            $this->aUnits = RcpUnitsQuery::create()->findPk($this->unit_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aUnits->addUserss($this);
             */
        }

        return $this->aUnits;
    }

    /**
     * Declares an association between this object and a RcpPositions object.
     *
     * @param             RcpPositions $v
     * @return RcpUsers The current object (for fluent API support)
     * @throws PropelException
     */
    public function setPositions(RcpPositions $v = null)
    {
        if ($v === null) {
            $this->setPositionId(NULL);
        } else {
            $this->setPositionId($v->getId());
        }

        $this->aPositions = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the RcpPositions object, it will not be re-added.
        if ($v !== null) {
            $v->addUsers($this);
        }


        return $this;
    }


    /**
     * Get the associated RcpPositions object
     *
     * @param PropelPDO $con Optional Connection object.
     * @return RcpPositions The associated RcpPositions object.
     * @throws PropelException
     */
    public function getPositions(PropelPDO $con = null)
    {
        if ($this->aPositions === null && ($this->position_id !== null)) {
            $this->aPositions = RcpPositionsQuery::create()->findPk($this->position_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aPositions->addUserss($this);
             */
        }

        return $this->aPositions;
    }


    /**
     * Initializes a collection based on the name of a relation.
     * Avoids crafting an 'init[$relationName]s' method name
     * that wouldn't work when StandardEnglishPluralizer is used.
     *
     * @param string $relationName The name of the relation to initialize
     * @return void
     */
    public function initRelation($relationName)
    {
        if ('LecturePresences' == $relationName) {
            $this->initLecturePresencess();
        }
        if ('AuthHistory' == $relationName) {
            $this->initAuthHistorys();
        }
        if ('CalendarEvents' == $relationName) {
            $this->initCalendarEventss();
        }
        if ('EventOrders' == $relationName) {
            $this->initEventOrderss();
        }
        if ('Lectures' == $relationName) {
            $this->initLecturess();
        }
        if ('UserHasLecture' == $relationName) {
            $this->initUserHasLectures();
        }
        if ('UserRoles' == $relationName) {
            $this->initUserRoless();
        }
        if ('SystemLogs' == $relationName) {
            $this->initSystemLogss();
        }
        if ('UserCalendars' == $relationName) {
            $this->initUserCalendarss();
        }
        if ('ViewCalendarEvents' == $relationName) {
            $this->initViewCalendarEventss();
        }
    }

    /**
     * Clears out the collLecturePresencess collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addLecturePresencess()
     */
    public function clearLecturePresencess()
    {
        $this->collLecturePresencess = null; // important to set this to null since that means it is uninitialized
        $this->collLecturePresencessPartial = null;
    }

    /**
     * reset is the collLecturePresencess collection loaded partially
     *
     * @return void
     */
    public function resetPartialLecturePresencess($v = true)
    {
        $this->collLecturePresencessPartial = $v;
    }

    /**
     * Initializes the collLecturePresencess collection.
     *
     * By default this just sets the collLecturePresencess collection to an empty array (like clearcollLecturePresencess());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initLecturePresencess($overrideExisting = true)
    {
        if (null !== $this->collLecturePresencess && !$overrideExisting) {
            return;
        }
        $this->collLecturePresencess = new PropelObjectCollection();
        $this->collLecturePresencess->setModel('RcpLecturePresences');
    }

    /**
     * Gets an array of RcpLecturePresences objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this RcpUsers is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|RcpLecturePresences[] List of RcpLecturePresences objects
     * @throws PropelException
     */
    public function getLecturePresencess($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collLecturePresencessPartial && !$this->isNew();
        if (null === $this->collLecturePresencess || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collLecturePresencess) {
                // return empty collection
                $this->initLecturePresencess();
            } else {
                $collLecturePresencess = RcpLecturePresencesQuery::create(null, $criteria)
                    ->filterByUsers($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collLecturePresencessPartial && count($collLecturePresencess)) {
                      $this->initLecturePresencess(false);

                      foreach($collLecturePresencess as $obj) {
                        if (false == $this->collLecturePresencess->contains($obj)) {
                          $this->collLecturePresencess->append($obj);
                        }
                      }

                      $this->collLecturePresencessPartial = true;
                    }

                    return $collLecturePresencess;
                }

                if($partial && $this->collLecturePresencess) {
                    foreach($this->collLecturePresencess as $obj) {
                        if($obj->isNew()) {
                            $collLecturePresencess[] = $obj;
                        }
                    }
                }

                $this->collLecturePresencess = $collLecturePresencess;
                $this->collLecturePresencessPartial = false;
            }
        }

        return $this->collLecturePresencess;
    }

    /**
     * Sets a collection of LecturePresences objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $lecturePresencess A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setLecturePresencess(PropelCollection $lecturePresencess, PropelPDO $con = null)
    {
        $this->lecturePresencessScheduledForDeletion = $this->getLecturePresencess(new Criteria(), $con)->diff($lecturePresencess);

        foreach ($this->lecturePresencessScheduledForDeletion as $lecturePresencesRemoved) {
            $lecturePresencesRemoved->setUsers(null);
        }

        $this->collLecturePresencess = null;
        foreach ($lecturePresencess as $lecturePresences) {
            $this->addLecturePresences($lecturePresences);
        }

        $this->collLecturePresencess = $lecturePresencess;
        $this->collLecturePresencessPartial = false;
    }

    /**
     * Returns the number of related RcpLecturePresences objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related RcpLecturePresences objects.
     * @throws PropelException
     */
    public function countLecturePresencess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collLecturePresencessPartial && !$this->isNew();
        if (null === $this->collLecturePresencess || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collLecturePresencess) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getLecturePresencess());
                }
                $query = RcpLecturePresencesQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByUsers($this)
                    ->count($con);
            }
        } else {
            return count($this->collLecturePresencess);
        }
    }

    /**
     * Method called to associate a RcpLecturePresences object to this object
     * through the RcpLecturePresences foreign key attribute.
     *
     * @param    RcpLecturePresences $l RcpLecturePresences
     * @return RcpUsers The current object (for fluent API support)
     */
    public function addLecturePresences(RcpLecturePresences $l)
    {
        if ($this->collLecturePresencess === null) {
            $this->initLecturePresencess();
            $this->collLecturePresencessPartial = true;
        }
        if (!$this->collLecturePresencess->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddLecturePresences($l);
        }

        return $this;
    }

    /**
     * @param	LecturePresences $lecturePresences The lecturePresences object to add.
     */
    protected function doAddLecturePresences($lecturePresences)
    {
        $this->collLecturePresencess[]= $lecturePresences;
        $lecturePresences->setUsers($this);
    }

    /**
     * @param	LecturePresences $lecturePresences The lecturePresences object to remove.
     */
    public function removeLecturePresences($lecturePresences)
    {
        if ($this->getLecturePresencess()->contains($lecturePresences)) {
            $this->collLecturePresencess->remove($this->collLecturePresencess->search($lecturePresences));
            if (null === $this->lecturePresencessScheduledForDeletion) {
                $this->lecturePresencessScheduledForDeletion = clone $this->collLecturePresencess;
                $this->lecturePresencessScheduledForDeletion->clear();
            }
            $this->lecturePresencessScheduledForDeletion[]= $lecturePresences;
            $lecturePresences->setUsers(null);
        }
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Users is new, it will return
     * an empty collection; or if this Users has previously
     * been saved, it will retrieve related LecturePresencess from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Users.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|RcpLecturePresences[] List of RcpLecturePresences objects
     */
    public function getLecturePresencessJoinLecutreHours($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = RcpLecturePresencesQuery::create(null, $criteria);
        $query->joinWith('LecutreHours', $join_behavior);

        return $this->getLecturePresencess($query, $con);
    }

    /**
     * Clears out the collAuthHistorys collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addAuthHistorys()
     */
    public function clearAuthHistorys()
    {
        $this->collAuthHistorys = null; // important to set this to null since that means it is uninitialized
        $this->collAuthHistorysPartial = null;
    }

    /**
     * reset is the collAuthHistorys collection loaded partially
     *
     * @return void
     */
    public function resetPartialAuthHistorys($v = true)
    {
        $this->collAuthHistorysPartial = $v;
    }

    /**
     * Initializes the collAuthHistorys collection.
     *
     * By default this just sets the collAuthHistorys collection to an empty array (like clearcollAuthHistorys());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initAuthHistorys($overrideExisting = true)
    {
        if (null !== $this->collAuthHistorys && !$overrideExisting) {
            return;
        }
        $this->collAuthHistorys = new PropelObjectCollection();
        $this->collAuthHistorys->setModel('RcpAuthHistory');
    }

    /**
     * Gets an array of RcpAuthHistory objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this RcpUsers is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|RcpAuthHistory[] List of RcpAuthHistory objects
     * @throws PropelException
     */
    public function getAuthHistorys($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collAuthHistorysPartial && !$this->isNew();
        if (null === $this->collAuthHistorys || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collAuthHistorys) {
                // return empty collection
                $this->initAuthHistorys();
            } else {
                $collAuthHistorys = RcpAuthHistoryQuery::create(null, $criteria)
                    ->filterByUsers($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collAuthHistorysPartial && count($collAuthHistorys)) {
                      $this->initAuthHistorys(false);

                      foreach($collAuthHistorys as $obj) {
                        if (false == $this->collAuthHistorys->contains($obj)) {
                          $this->collAuthHistorys->append($obj);
                        }
                      }

                      $this->collAuthHistorysPartial = true;
                    }

                    return $collAuthHistorys;
                }

                if($partial && $this->collAuthHistorys) {
                    foreach($this->collAuthHistorys as $obj) {
                        if($obj->isNew()) {
                            $collAuthHistorys[] = $obj;
                        }
                    }
                }

                $this->collAuthHistorys = $collAuthHistorys;
                $this->collAuthHistorysPartial = false;
            }
        }

        return $this->collAuthHistorys;
    }

    /**
     * Sets a collection of AuthHistory objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $authHistorys A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setAuthHistorys(PropelCollection $authHistorys, PropelPDO $con = null)
    {
        $this->authHistorysScheduledForDeletion = $this->getAuthHistorys(new Criteria(), $con)->diff($authHistorys);

        foreach ($this->authHistorysScheduledForDeletion as $authHistoryRemoved) {
            $authHistoryRemoved->setUsers(null);
        }

        $this->collAuthHistorys = null;
        foreach ($authHistorys as $authHistory) {
            $this->addAuthHistory($authHistory);
        }

        $this->collAuthHistorys = $authHistorys;
        $this->collAuthHistorysPartial = false;
    }

    /**
     * Returns the number of related RcpAuthHistory objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related RcpAuthHistory objects.
     * @throws PropelException
     */
    public function countAuthHistorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collAuthHistorysPartial && !$this->isNew();
        if (null === $this->collAuthHistorys || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collAuthHistorys) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getAuthHistorys());
                }
                $query = RcpAuthHistoryQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByUsers($this)
                    ->count($con);
            }
        } else {
            return count($this->collAuthHistorys);
        }
    }

    /**
     * Method called to associate a RcpAuthHistory object to this object
     * through the RcpAuthHistory foreign key attribute.
     *
     * @param    RcpAuthHistory $l RcpAuthHistory
     * @return RcpUsers The current object (for fluent API support)
     */
    public function addAuthHistory(RcpAuthHistory $l)
    {
        if ($this->collAuthHistorys === null) {
            $this->initAuthHistorys();
            $this->collAuthHistorysPartial = true;
        }
        if (!$this->collAuthHistorys->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddAuthHistory($l);
        }

        return $this;
    }

    /**
     * @param	AuthHistory $authHistory The authHistory object to add.
     */
    protected function doAddAuthHistory($authHistory)
    {
        $this->collAuthHistorys[]= $authHistory;
        $authHistory->setUsers($this);
    }

    /**
     * @param	AuthHistory $authHistory The authHistory object to remove.
     */
    public function removeAuthHistory($authHistory)
    {
        if ($this->getAuthHistorys()->contains($authHistory)) {
            $this->collAuthHistorys->remove($this->collAuthHistorys->search($authHistory));
            if (null === $this->authHistorysScheduledForDeletion) {
                $this->authHistorysScheduledForDeletion = clone $this->collAuthHistorys;
                $this->authHistorysScheduledForDeletion->clear();
            }
            $this->authHistorysScheduledForDeletion[]= $authHistory;
            $authHistory->setUsers(null);
        }
    }

    /**
     * Clears out the collCalendarEventss collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addCalendarEventss()
     */
    public function clearCalendarEventss()
    {
        $this->collCalendarEventss = null; // important to set this to null since that means it is uninitialized
        $this->collCalendarEventssPartial = null;
    }

    /**
     * reset is the collCalendarEventss collection loaded partially
     *
     * @return void
     */
    public function resetPartialCalendarEventss($v = true)
    {
        $this->collCalendarEventssPartial = $v;
    }

    /**
     * Initializes the collCalendarEventss collection.
     *
     * By default this just sets the collCalendarEventss collection to an empty array (like clearcollCalendarEventss());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initCalendarEventss($overrideExisting = true)
    {
        if (null !== $this->collCalendarEventss && !$overrideExisting) {
            return;
        }
        $this->collCalendarEventss = new PropelObjectCollection();
        $this->collCalendarEventss->setModel('RcpCalendarEvents');
    }

    /**
     * Gets an array of RcpCalendarEvents objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this RcpUsers is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|RcpCalendarEvents[] List of RcpCalendarEvents objects
     * @throws PropelException
     */
    public function getCalendarEventss($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collCalendarEventssPartial && !$this->isNew();
        if (null === $this->collCalendarEventss || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collCalendarEventss) {
                // return empty collection
                $this->initCalendarEventss();
            } else {
                $collCalendarEventss = RcpCalendarEventsQuery::create(null, $criteria)
                    ->filterByUsers($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collCalendarEventssPartial && count($collCalendarEventss)) {
                      $this->initCalendarEventss(false);

                      foreach($collCalendarEventss as $obj) {
                        if (false == $this->collCalendarEventss->contains($obj)) {
                          $this->collCalendarEventss->append($obj);
                        }
                      }

                      $this->collCalendarEventssPartial = true;
                    }

                    return $collCalendarEventss;
                }

                if($partial && $this->collCalendarEventss) {
                    foreach($this->collCalendarEventss as $obj) {
                        if($obj->isNew()) {
                            $collCalendarEventss[] = $obj;
                        }
                    }
                }

                $this->collCalendarEventss = $collCalendarEventss;
                $this->collCalendarEventssPartial = false;
            }
        }

        return $this->collCalendarEventss;
    }

    /**
     * Sets a collection of CalendarEvents objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $calendarEventss A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setCalendarEventss(PropelCollection $calendarEventss, PropelPDO $con = null)
    {
        $this->calendarEventssScheduledForDeletion = $this->getCalendarEventss(new Criteria(), $con)->diff($calendarEventss);

        foreach ($this->calendarEventssScheduledForDeletion as $calendarEventsRemoved) {
            $calendarEventsRemoved->setUsers(null);
        }

        $this->collCalendarEventss = null;
        foreach ($calendarEventss as $calendarEvents) {
            $this->addCalendarEvents($calendarEvents);
        }

        $this->collCalendarEventss = $calendarEventss;
        $this->collCalendarEventssPartial = false;
    }

    /**
     * Returns the number of related RcpCalendarEvents objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related RcpCalendarEvents objects.
     * @throws PropelException
     */
    public function countCalendarEventss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collCalendarEventssPartial && !$this->isNew();
        if (null === $this->collCalendarEventss || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collCalendarEventss) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getCalendarEventss());
                }
                $query = RcpCalendarEventsQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByUsers($this)
                    ->count($con);
            }
        } else {
            return count($this->collCalendarEventss);
        }
    }

    /**
     * Method called to associate a RcpCalendarEvents object to this object
     * through the RcpCalendarEvents foreign key attribute.
     *
     * @param    RcpCalendarEvents $l RcpCalendarEvents
     * @return RcpUsers The current object (for fluent API support)
     */
    public function addCalendarEvents(RcpCalendarEvents $l)
    {
        if ($this->collCalendarEventss === null) {
            $this->initCalendarEventss();
            $this->collCalendarEventssPartial = true;
        }
        if (!$this->collCalendarEventss->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddCalendarEvents($l);
        }

        return $this;
    }

    /**
     * @param	CalendarEvents $calendarEvents The calendarEvents object to add.
     */
    protected function doAddCalendarEvents($calendarEvents)
    {
        $this->collCalendarEventss[]= $calendarEvents;
        $calendarEvents->setUsers($this);
    }

    /**
     * @param	CalendarEvents $calendarEvents The calendarEvents object to remove.
     */
    public function removeCalendarEvents($calendarEvents)
    {
        if ($this->getCalendarEventss()->contains($calendarEvents)) {
            $this->collCalendarEventss->remove($this->collCalendarEventss->search($calendarEvents));
            if (null === $this->calendarEventssScheduledForDeletion) {
                $this->calendarEventssScheduledForDeletion = clone $this->collCalendarEventss;
                $this->calendarEventssScheduledForDeletion->clear();
            }
            $this->calendarEventssScheduledForDeletion[]= $calendarEvents;
            $calendarEvents->setUsers(null);
        }
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Users is new, it will return
     * an empty collection; or if this Users has previously
     * been saved, it will retrieve related CalendarEventss from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Users.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|RcpCalendarEvents[] List of RcpCalendarEvents objects
     */
    public function getCalendarEventssJoinEventDefs($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = RcpCalendarEventsQuery::create(null, $criteria);
        $query->joinWith('EventDefs', $join_behavior);

        return $this->getCalendarEventss($query, $con);
    }

    /**
     * Clears out the collEventOrderss collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addEventOrderss()
     */
    public function clearEventOrderss()
    {
        $this->collEventOrderss = null; // important to set this to null since that means it is uninitialized
        $this->collEventOrderssPartial = null;
    }

    /**
     * reset is the collEventOrderss collection loaded partially
     *
     * @return void
     */
    public function resetPartialEventOrderss($v = true)
    {
        $this->collEventOrderssPartial = $v;
    }

    /**
     * Initializes the collEventOrderss collection.
     *
     * By default this just sets the collEventOrderss collection to an empty array (like clearcollEventOrderss());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initEventOrderss($overrideExisting = true)
    {
        if (null !== $this->collEventOrderss && !$overrideExisting) {
            return;
        }
        $this->collEventOrderss = new PropelObjectCollection();
        $this->collEventOrderss->setModel('RcpEventOrders');
    }

    /**
     * Gets an array of RcpEventOrders objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this RcpUsers is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|RcpEventOrders[] List of RcpEventOrders objects
     * @throws PropelException
     */
    public function getEventOrderss($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collEventOrderssPartial && !$this->isNew();
        if (null === $this->collEventOrderss || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collEventOrderss) {
                // return empty collection
                $this->initEventOrderss();
            } else {
                $collEventOrderss = RcpEventOrdersQuery::create(null, $criteria)
                    ->filterByUsers($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collEventOrderssPartial && count($collEventOrderss)) {
                      $this->initEventOrderss(false);

                      foreach($collEventOrderss as $obj) {
                        if (false == $this->collEventOrderss->contains($obj)) {
                          $this->collEventOrderss->append($obj);
                        }
                      }

                      $this->collEventOrderssPartial = true;
                    }

                    return $collEventOrderss;
                }

                if($partial && $this->collEventOrderss) {
                    foreach($this->collEventOrderss as $obj) {
                        if($obj->isNew()) {
                            $collEventOrderss[] = $obj;
                        }
                    }
                }

                $this->collEventOrderss = $collEventOrderss;
                $this->collEventOrderssPartial = false;
            }
        }

        return $this->collEventOrderss;
    }

    /**
     * Sets a collection of EventOrders objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $eventOrderss A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setEventOrderss(PropelCollection $eventOrderss, PropelPDO $con = null)
    {
        $this->eventOrderssScheduledForDeletion = $this->getEventOrderss(new Criteria(), $con)->diff($eventOrderss);

        foreach ($this->eventOrderssScheduledForDeletion as $eventOrdersRemoved) {
            $eventOrdersRemoved->setUsers(null);
        }

        $this->collEventOrderss = null;
        foreach ($eventOrderss as $eventOrders) {
            $this->addEventOrders($eventOrders);
        }

        $this->collEventOrderss = $eventOrderss;
        $this->collEventOrderssPartial = false;
    }

    /**
     * Returns the number of related RcpEventOrders objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related RcpEventOrders objects.
     * @throws PropelException
     */
    public function countEventOrderss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collEventOrderssPartial && !$this->isNew();
        if (null === $this->collEventOrderss || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collEventOrderss) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getEventOrderss());
                }
                $query = RcpEventOrdersQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByUsers($this)
                    ->count($con);
            }
        } else {
            return count($this->collEventOrderss);
        }
    }

    /**
     * Method called to associate a RcpEventOrders object to this object
     * through the RcpEventOrders foreign key attribute.
     *
     * @param    RcpEventOrders $l RcpEventOrders
     * @return RcpUsers The current object (for fluent API support)
     */
    public function addEventOrders(RcpEventOrders $l)
    {
        if ($this->collEventOrderss === null) {
            $this->initEventOrderss();
            $this->collEventOrderssPartial = true;
        }
        if (!$this->collEventOrderss->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddEventOrders($l);
        }

        return $this;
    }

    /**
     * @param	EventOrders $eventOrders The eventOrders object to add.
     */
    protected function doAddEventOrders($eventOrders)
    {
        $this->collEventOrderss[]= $eventOrders;
        $eventOrders->setUsers($this);
    }

    /**
     * @param	EventOrders $eventOrders The eventOrders object to remove.
     */
    public function removeEventOrders($eventOrders)
    {
        if ($this->getEventOrderss()->contains($eventOrders)) {
            $this->collEventOrderss->remove($this->collEventOrderss->search($eventOrders));
            if (null === $this->eventOrderssScheduledForDeletion) {
                $this->eventOrderssScheduledForDeletion = clone $this->collEventOrderss;
                $this->eventOrderssScheduledForDeletion->clear();
            }
            $this->eventOrderssScheduledForDeletion[]= $eventOrders;
            $eventOrders->setUsers(null);
        }
    }

    /**
     * Clears out the collLecturess collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addLecturess()
     */
    public function clearLecturess()
    {
        $this->collLecturess = null; // important to set this to null since that means it is uninitialized
        $this->collLecturessPartial = null;
    }

    /**
     * reset is the collLecturess collection loaded partially
     *
     * @return void
     */
    public function resetPartialLecturess($v = true)
    {
        $this->collLecturessPartial = $v;
    }

    /**
     * Initializes the collLecturess collection.
     *
     * By default this just sets the collLecturess collection to an empty array (like clearcollLecturess());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initLecturess($overrideExisting = true)
    {
        if (null !== $this->collLecturess && !$overrideExisting) {
            return;
        }
        $this->collLecturess = new PropelObjectCollection();
        $this->collLecturess->setModel('RcpLectures');
    }

    /**
     * Gets an array of RcpLectures objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this RcpUsers is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|RcpLectures[] List of RcpLectures objects
     * @throws PropelException
     */
    public function getLecturess($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collLecturessPartial && !$this->isNew();
        if (null === $this->collLecturess || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collLecturess) {
                // return empty collection
                $this->initLecturess();
            } else {
                $collLecturess = RcpLecturesQuery::create(null, $criteria)
                    ->filterByUsers($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collLecturessPartial && count($collLecturess)) {
                      $this->initLecturess(false);

                      foreach($collLecturess as $obj) {
                        if (false == $this->collLecturess->contains($obj)) {
                          $this->collLecturess->append($obj);
                        }
                      }

                      $this->collLecturessPartial = true;
                    }

                    return $collLecturess;
                }

                if($partial && $this->collLecturess) {
                    foreach($this->collLecturess as $obj) {
                        if($obj->isNew()) {
                            $collLecturess[] = $obj;
                        }
                    }
                }

                $this->collLecturess = $collLecturess;
                $this->collLecturessPartial = false;
            }
        }

        return $this->collLecturess;
    }

    /**
     * Sets a collection of Lectures objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $lecturess A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setLecturess(PropelCollection $lecturess, PropelPDO $con = null)
    {
        $this->lecturessScheduledForDeletion = $this->getLecturess(new Criteria(), $con)->diff($lecturess);

        foreach ($this->lecturessScheduledForDeletion as $lecturesRemoved) {
            $lecturesRemoved->setUsers(null);
        }

        $this->collLecturess = null;
        foreach ($lecturess as $lectures) {
            $this->addLectures($lectures);
        }

        $this->collLecturess = $lecturess;
        $this->collLecturessPartial = false;
    }

    /**
     * Returns the number of related RcpLectures objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related RcpLectures objects.
     * @throws PropelException
     */
    public function countLecturess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collLecturessPartial && !$this->isNew();
        if (null === $this->collLecturess || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collLecturess) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getLecturess());
                }
                $query = RcpLecturesQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByUsers($this)
                    ->count($con);
            }
        } else {
            return count($this->collLecturess);
        }
    }

    /**
     * Method called to associate a RcpLectures object to this object
     * through the RcpLectures foreign key attribute.
     *
     * @param    RcpLectures $l RcpLectures
     * @return RcpUsers The current object (for fluent API support)
     */
    public function addLectures(RcpLectures $l)
    {
        if ($this->collLecturess === null) {
            $this->initLecturess();
            $this->collLecturessPartial = true;
        }
        if (!$this->collLecturess->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddLectures($l);
        }

        return $this;
    }

    /**
     * @param	Lectures $lectures The lectures object to add.
     */
    protected function doAddLectures($lectures)
    {
        $this->collLecturess[]= $lectures;
        $lectures->setUsers($this);
    }

    /**
     * @param	Lectures $lectures The lectures object to remove.
     */
    public function removeLectures($lectures)
    {
        if ($this->getLecturess()->contains($lectures)) {
            $this->collLecturess->remove($this->collLecturess->search($lectures));
            if (null === $this->lecturessScheduledForDeletion) {
                $this->lecturessScheduledForDeletion = clone $this->collLecturess;
                $this->lecturessScheduledForDeletion->clear();
            }
            $this->lecturessScheduledForDeletion[]= $lectures;
            $lectures->setUsers(null);
        }
    }

    /**
     * Clears out the collUserHasLectures collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addUserHasLectures()
     */
    public function clearUserHasLectures()
    {
        $this->collUserHasLectures = null; // important to set this to null since that means it is uninitialized
        $this->collUserHasLecturesPartial = null;
    }

    /**
     * reset is the collUserHasLectures collection loaded partially
     *
     * @return void
     */
    public function resetPartialUserHasLectures($v = true)
    {
        $this->collUserHasLecturesPartial = $v;
    }

    /**
     * Initializes the collUserHasLectures collection.
     *
     * By default this just sets the collUserHasLectures collection to an empty array (like clearcollUserHasLectures());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initUserHasLectures($overrideExisting = true)
    {
        if (null !== $this->collUserHasLectures && !$overrideExisting) {
            return;
        }
        $this->collUserHasLectures = new PropelObjectCollection();
        $this->collUserHasLectures->setModel('RcpUserHasLecture');
    }

    /**
     * Gets an array of RcpUserHasLecture objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this RcpUsers is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|RcpUserHasLecture[] List of RcpUserHasLecture objects
     * @throws PropelException
     */
    public function getUserHasLectures($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collUserHasLecturesPartial && !$this->isNew();
        if (null === $this->collUserHasLectures || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collUserHasLectures) {
                // return empty collection
                $this->initUserHasLectures();
            } else {
                $collUserHasLectures = RcpUserHasLectureQuery::create(null, $criteria)
                    ->filterByUsers($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collUserHasLecturesPartial && count($collUserHasLectures)) {
                      $this->initUserHasLectures(false);

                      foreach($collUserHasLectures as $obj) {
                        if (false == $this->collUserHasLectures->contains($obj)) {
                          $this->collUserHasLectures->append($obj);
                        }
                      }

                      $this->collUserHasLecturesPartial = true;
                    }

                    return $collUserHasLectures;
                }

                if($partial && $this->collUserHasLectures) {
                    foreach($this->collUserHasLectures as $obj) {
                        if($obj->isNew()) {
                            $collUserHasLectures[] = $obj;
                        }
                    }
                }

                $this->collUserHasLectures = $collUserHasLectures;
                $this->collUserHasLecturesPartial = false;
            }
        }

        return $this->collUserHasLectures;
    }

    /**
     * Sets a collection of UserHasLecture objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $userHasLectures A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setUserHasLectures(PropelCollection $userHasLectures, PropelPDO $con = null)
    {
        $this->userHasLecturesScheduledForDeletion = $this->getUserHasLectures(new Criteria(), $con)->diff($userHasLectures);

        foreach ($this->userHasLecturesScheduledForDeletion as $userHasLectureRemoved) {
            $userHasLectureRemoved->setUsers(null);
        }

        $this->collUserHasLectures = null;
        foreach ($userHasLectures as $userHasLecture) {
            $this->addUserHasLecture($userHasLecture);
        }

        $this->collUserHasLectures = $userHasLectures;
        $this->collUserHasLecturesPartial = false;
    }

    /**
     * Returns the number of related RcpUserHasLecture objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related RcpUserHasLecture objects.
     * @throws PropelException
     */
    public function countUserHasLectures(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collUserHasLecturesPartial && !$this->isNew();
        if (null === $this->collUserHasLectures || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collUserHasLectures) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getUserHasLectures());
                }
                $query = RcpUserHasLectureQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByUsers($this)
                    ->count($con);
            }
        } else {
            return count($this->collUserHasLectures);
        }
    }

    /**
     * Method called to associate a RcpUserHasLecture object to this object
     * through the RcpUserHasLecture foreign key attribute.
     *
     * @param    RcpUserHasLecture $l RcpUserHasLecture
     * @return RcpUsers The current object (for fluent API support)
     */
    public function addUserHasLecture(RcpUserHasLecture $l)
    {
        if ($this->collUserHasLectures === null) {
            $this->initUserHasLectures();
            $this->collUserHasLecturesPartial = true;
        }
        if (!$this->collUserHasLectures->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddUserHasLecture($l);
        }

        return $this;
    }

    /**
     * @param	UserHasLecture $userHasLecture The userHasLecture object to add.
     */
    protected function doAddUserHasLecture($userHasLecture)
    {
        $this->collUserHasLectures[]= $userHasLecture;
        $userHasLecture->setUsers($this);
    }

    /**
     * @param	UserHasLecture $userHasLecture The userHasLecture object to remove.
     */
    public function removeUserHasLecture($userHasLecture)
    {
        if ($this->getUserHasLectures()->contains($userHasLecture)) {
            $this->collUserHasLectures->remove($this->collUserHasLectures->search($userHasLecture));
            if (null === $this->userHasLecturesScheduledForDeletion) {
                $this->userHasLecturesScheduledForDeletion = clone $this->collUserHasLectures;
                $this->userHasLecturesScheduledForDeletion->clear();
            }
            $this->userHasLecturesScheduledForDeletion[]= $userHasLecture;
            $userHasLecture->setUsers(null);
        }
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Users is new, it will return
     * an empty collection; or if this Users has previously
     * been saved, it will retrieve related UserHasLectures from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Users.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|RcpUserHasLecture[] List of RcpUserHasLecture objects
     */
    public function getUserHasLecturesJoinLectures($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = RcpUserHasLectureQuery::create(null, $criteria);
        $query->joinWith('Lectures', $join_behavior);

        return $this->getUserHasLectures($query, $con);
    }

    /**
     * Clears out the collUserRoless collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addUserRoless()
     */
    public function clearUserRoless()
    {
        $this->collUserRoless = null; // important to set this to null since that means it is uninitialized
        $this->collUserRolessPartial = null;
    }

    /**
     * reset is the collUserRoless collection loaded partially
     *
     * @return void
     */
    public function resetPartialUserRoless($v = true)
    {
        $this->collUserRolessPartial = $v;
    }

    /**
     * Initializes the collUserRoless collection.
     *
     * By default this just sets the collUserRoless collection to an empty array (like clearcollUserRoless());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initUserRoless($overrideExisting = true)
    {
        if (null !== $this->collUserRoless && !$overrideExisting) {
            return;
        }
        $this->collUserRoless = new PropelObjectCollection();
        $this->collUserRoless->setModel('RcpUserRoles');
    }

    /**
     * Gets an array of RcpUserRoles objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this RcpUsers is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|RcpUserRoles[] List of RcpUserRoles objects
     * @throws PropelException
     */
    public function getUserRoless($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collUserRolessPartial && !$this->isNew();
        if (null === $this->collUserRoless || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collUserRoless) {
                // return empty collection
                $this->initUserRoless();
            } else {
                $collUserRoless = RcpUserRolesQuery::create(null, $criteria)
                    ->filterByUsers($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collUserRolessPartial && count($collUserRoless)) {
                      $this->initUserRoless(false);

                      foreach($collUserRoless as $obj) {
                        if (false == $this->collUserRoless->contains($obj)) {
                          $this->collUserRoless->append($obj);
                        }
                      }

                      $this->collUserRolessPartial = true;
                    }

                    return $collUserRoless;
                }

                if($partial && $this->collUserRoless) {
                    foreach($this->collUserRoless as $obj) {
                        if($obj->isNew()) {
                            $collUserRoless[] = $obj;
                        }
                    }
                }

                $this->collUserRoless = $collUserRoless;
                $this->collUserRolessPartial = false;
            }
        }

        return $this->collUserRoless;
    }

    /**
     * Sets a collection of UserRoles objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $userRoless A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setUserRoless(PropelCollection $userRoless, PropelPDO $con = null)
    {
        $this->userRolessScheduledForDeletion = $this->getUserRoless(new Criteria(), $con)->diff($userRoless);

        foreach ($this->userRolessScheduledForDeletion as $userRolesRemoved) {
            $userRolesRemoved->setUsers(null);
        }

        $this->collUserRoless = null;
        foreach ($userRoless as $userRoles) {
            $this->addUserRoles($userRoles);
        }

        $this->collUserRoless = $userRoless;
        $this->collUserRolessPartial = false;
    }

    /**
     * Returns the number of related RcpUserRoles objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related RcpUserRoles objects.
     * @throws PropelException
     */
    public function countUserRoless(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collUserRolessPartial && !$this->isNew();
        if (null === $this->collUserRoless || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collUserRoless) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getUserRoless());
                }
                $query = RcpUserRolesQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByUsers($this)
                    ->count($con);
            }
        } else {
            return count($this->collUserRoless);
        }
    }

    /**
     * Method called to associate a RcpUserRoles object to this object
     * through the RcpUserRoles foreign key attribute.
     *
     * @param    RcpUserRoles $l RcpUserRoles
     * @return RcpUsers The current object (for fluent API support)
     */
    public function addUserRoles(RcpUserRoles $l)
    {
        if ($this->collUserRoless === null) {
            $this->initUserRoless();
            $this->collUserRolessPartial = true;
        }
        if (!$this->collUserRoless->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddUserRoles($l);
        }

        return $this;
    }

    /**
     * @param	UserRoles $userRoles The userRoles object to add.
     */
    protected function doAddUserRoles($userRoles)
    {
        $this->collUserRoless[]= $userRoles;
        $userRoles->setUsers($this);
    }

    /**
     * @param	UserRoles $userRoles The userRoles object to remove.
     */
    public function removeUserRoles($userRoles)
    {
        if ($this->getUserRoless()->contains($userRoles)) {
            $this->collUserRoless->remove($this->collUserRoless->search($userRoles));
            if (null === $this->userRolessScheduledForDeletion) {
                $this->userRolessScheduledForDeletion = clone $this->collUserRoless;
                $this->userRolessScheduledForDeletion->clear();
            }
            $this->userRolessScheduledForDeletion[]= $userRoles;
            $userRoles->setUsers(null);
        }
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Users is new, it will return
     * an empty collection; or if this Users has previously
     * been saved, it will retrieve related UserRoless from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Users.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|RcpUserRoles[] List of RcpUserRoles objects
     */
    public function getUserRolessJoinRoles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = RcpUserRolesQuery::create(null, $criteria);
        $query->joinWith('Roles', $join_behavior);

        return $this->getUserRoless($query, $con);
    }

    /**
     * Clears out the collSystemLogss collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addSystemLogss()
     */
    public function clearSystemLogss()
    {
        $this->collSystemLogss = null; // important to set this to null since that means it is uninitialized
        $this->collSystemLogssPartial = null;
    }

    /**
     * reset is the collSystemLogss collection loaded partially
     *
     * @return void
     */
    public function resetPartialSystemLogss($v = true)
    {
        $this->collSystemLogssPartial = $v;
    }

    /**
     * Initializes the collSystemLogss collection.
     *
     * By default this just sets the collSystemLogss collection to an empty array (like clearcollSystemLogss());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initSystemLogss($overrideExisting = true)
    {
        if (null !== $this->collSystemLogss && !$overrideExisting) {
            return;
        }
        $this->collSystemLogss = new PropelObjectCollection();
        $this->collSystemLogss->setModel('RcpSystemLogs');
    }

    /**
     * Gets an array of RcpSystemLogs objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this RcpUsers is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|RcpSystemLogs[] List of RcpSystemLogs objects
     * @throws PropelException
     */
    public function getSystemLogss($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collSystemLogssPartial && !$this->isNew();
        if (null === $this->collSystemLogss || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collSystemLogss) {
                // return empty collection
                $this->initSystemLogss();
            } else {
                $collSystemLogss = RcpSystemLogsQuery::create(null, $criteria)
                    ->filterByUsers($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collSystemLogssPartial && count($collSystemLogss)) {
                      $this->initSystemLogss(false);

                      foreach($collSystemLogss as $obj) {
                        if (false == $this->collSystemLogss->contains($obj)) {
                          $this->collSystemLogss->append($obj);
                        }
                      }

                      $this->collSystemLogssPartial = true;
                    }

                    return $collSystemLogss;
                }

                if($partial && $this->collSystemLogss) {
                    foreach($this->collSystemLogss as $obj) {
                        if($obj->isNew()) {
                            $collSystemLogss[] = $obj;
                        }
                    }
                }

                $this->collSystemLogss = $collSystemLogss;
                $this->collSystemLogssPartial = false;
            }
        }

        return $this->collSystemLogss;
    }

    /**
     * Sets a collection of SystemLogs objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $systemLogss A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setSystemLogss(PropelCollection $systemLogss, PropelPDO $con = null)
    {
        $this->systemLogssScheduledForDeletion = $this->getSystemLogss(new Criteria(), $con)->diff($systemLogss);

        foreach ($this->systemLogssScheduledForDeletion as $systemLogsRemoved) {
            $systemLogsRemoved->setUsers(null);
        }

        $this->collSystemLogss = null;
        foreach ($systemLogss as $systemLogs) {
            $this->addSystemLogs($systemLogs);
        }

        $this->collSystemLogss = $systemLogss;
        $this->collSystemLogssPartial = false;
    }

    /**
     * Returns the number of related RcpSystemLogs objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related RcpSystemLogs objects.
     * @throws PropelException
     */
    public function countSystemLogss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collSystemLogssPartial && !$this->isNew();
        if (null === $this->collSystemLogss || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collSystemLogss) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getSystemLogss());
                }
                $query = RcpSystemLogsQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByUsers($this)
                    ->count($con);
            }
        } else {
            return count($this->collSystemLogss);
        }
    }

    /**
     * Method called to associate a RcpSystemLogs object to this object
     * through the RcpSystemLogs foreign key attribute.
     *
     * @param    RcpSystemLogs $l RcpSystemLogs
     * @return RcpUsers The current object (for fluent API support)
     */
    public function addSystemLogs(RcpSystemLogs $l)
    {
        if ($this->collSystemLogss === null) {
            $this->initSystemLogss();
            $this->collSystemLogssPartial = true;
        }
        if (!$this->collSystemLogss->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddSystemLogs($l);
        }

        return $this;
    }

    /**
     * @param	SystemLogs $systemLogs The systemLogs object to add.
     */
    protected function doAddSystemLogs($systemLogs)
    {
        $this->collSystemLogss[]= $systemLogs;
        $systemLogs->setUsers($this);
    }

    /**
     * @param	SystemLogs $systemLogs The systemLogs object to remove.
     */
    public function removeSystemLogs($systemLogs)
    {
        if ($this->getSystemLogss()->contains($systemLogs)) {
            $this->collSystemLogss->remove($this->collSystemLogss->search($systemLogs));
            if (null === $this->systemLogssScheduledForDeletion) {
                $this->systemLogssScheduledForDeletion = clone $this->collSystemLogss;
                $this->systemLogssScheduledForDeletion->clear();
            }
            $this->systemLogssScheduledForDeletion[]= $systemLogs;
            $systemLogs->setUsers(null);
        }
    }

    /**
     * Clears out the collUserCalendarss collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addUserCalendarss()
     */
    public function clearUserCalendarss()
    {
        $this->collUserCalendarss = null; // important to set this to null since that means it is uninitialized
        $this->collUserCalendarssPartial = null;
    }

    /**
     * reset is the collUserCalendarss collection loaded partially
     *
     * @return void
     */
    public function resetPartialUserCalendarss($v = true)
    {
        $this->collUserCalendarssPartial = $v;
    }

    /**
     * Initializes the collUserCalendarss collection.
     *
     * By default this just sets the collUserCalendarss collection to an empty array (like clearcollUserCalendarss());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initUserCalendarss($overrideExisting = true)
    {
        if (null !== $this->collUserCalendarss && !$overrideExisting) {
            return;
        }
        $this->collUserCalendarss = new PropelObjectCollection();
        $this->collUserCalendarss->setModel('RcpUserCalendars');
    }

    /**
     * Gets an array of RcpUserCalendars objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this RcpUsers is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|RcpUserCalendars[] List of RcpUserCalendars objects
     * @throws PropelException
     */
    public function getUserCalendarss($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collUserCalendarssPartial && !$this->isNew();
        if (null === $this->collUserCalendarss || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collUserCalendarss) {
                // return empty collection
                $this->initUserCalendarss();
            } else {
                $collUserCalendarss = RcpUserCalendarsQuery::create(null, $criteria)
                    ->filterByUsers($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collUserCalendarssPartial && count($collUserCalendarss)) {
                      $this->initUserCalendarss(false);

                      foreach($collUserCalendarss as $obj) {
                        if (false == $this->collUserCalendarss->contains($obj)) {
                          $this->collUserCalendarss->append($obj);
                        }
                      }

                      $this->collUserCalendarssPartial = true;
                    }

                    return $collUserCalendarss;
                }

                if($partial && $this->collUserCalendarss) {
                    foreach($this->collUserCalendarss as $obj) {
                        if($obj->isNew()) {
                            $collUserCalendarss[] = $obj;
                        }
                    }
                }

                $this->collUserCalendarss = $collUserCalendarss;
                $this->collUserCalendarssPartial = false;
            }
        }

        return $this->collUserCalendarss;
    }

    /**
     * Sets a collection of UserCalendars objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $userCalendarss A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setUserCalendarss(PropelCollection $userCalendarss, PropelPDO $con = null)
    {
        $this->userCalendarssScheduledForDeletion = $this->getUserCalendarss(new Criteria(), $con)->diff($userCalendarss);

        foreach ($this->userCalendarssScheduledForDeletion as $userCalendarsRemoved) {
            $userCalendarsRemoved->setUsers(null);
        }

        $this->collUserCalendarss = null;
        foreach ($userCalendarss as $userCalendars) {
            $this->addUserCalendars($userCalendars);
        }

        $this->collUserCalendarss = $userCalendarss;
        $this->collUserCalendarssPartial = false;
    }

    /**
     * Returns the number of related RcpUserCalendars objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related RcpUserCalendars objects.
     * @throws PropelException
     */
    public function countUserCalendarss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collUserCalendarssPartial && !$this->isNew();
        if (null === $this->collUserCalendarss || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collUserCalendarss) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getUserCalendarss());
                }
                $query = RcpUserCalendarsQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByUsers($this)
                    ->count($con);
            }
        } else {
            return count($this->collUserCalendarss);
        }
    }

    /**
     * Method called to associate a RcpUserCalendars object to this object
     * through the RcpUserCalendars foreign key attribute.
     *
     * @param    RcpUserCalendars $l RcpUserCalendars
     * @return RcpUsers The current object (for fluent API support)
     */
    public function addUserCalendars(RcpUserCalendars $l)
    {
        if ($this->collUserCalendarss === null) {
            $this->initUserCalendarss();
            $this->collUserCalendarssPartial = true;
        }
        if (!$this->collUserCalendarss->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddUserCalendars($l);
        }

        return $this;
    }

    /**
     * @param	UserCalendars $userCalendars The userCalendars object to add.
     */
    protected function doAddUserCalendars($userCalendars)
    {
        $this->collUserCalendarss[]= $userCalendars;
        $userCalendars->setUsers($this);
    }

    /**
     * @param	UserCalendars $userCalendars The userCalendars object to remove.
     */
    public function removeUserCalendars($userCalendars)
    {
        if ($this->getUserCalendarss()->contains($userCalendars)) {
            $this->collUserCalendarss->remove($this->collUserCalendarss->search($userCalendars));
            if (null === $this->userCalendarssScheduledForDeletion) {
                $this->userCalendarssScheduledForDeletion = clone $this->collUserCalendarss;
                $this->userCalendarssScheduledForDeletion->clear();
            }
            $this->userCalendarssScheduledForDeletion[]= $userCalendars;
            $userCalendars->setUsers(null);
        }
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Users is new, it will return
     * an empty collection; or if this Users has previously
     * been saved, it will retrieve related UserCalendarss from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Users.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|RcpUserCalendars[] List of RcpUserCalendars objects
     */
    public function getUserCalendarssJoinCalendars($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = RcpUserCalendarsQuery::create(null, $criteria);
        $query->joinWith('Calendars', $join_behavior);

        return $this->getUserCalendarss($query, $con);
    }

    /**
     * Clears out the collViewCalendarEventss collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addViewCalendarEventss()
     */
    public function clearViewCalendarEventss()
    {
        $this->collViewCalendarEventss = null; // important to set this to null since that means it is uninitialized
        $this->collViewCalendarEventssPartial = null;
    }

    /**
     * reset is the collViewCalendarEventss collection loaded partially
     *
     * @return void
     */
    public function resetPartialViewCalendarEventss($v = true)
    {
        $this->collViewCalendarEventssPartial = $v;
    }

    /**
     * Initializes the collViewCalendarEventss collection.
     *
     * By default this just sets the collViewCalendarEventss collection to an empty array (like clearcollViewCalendarEventss());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initViewCalendarEventss($overrideExisting = true)
    {
        if (null !== $this->collViewCalendarEventss && !$overrideExisting) {
            return;
        }
        $this->collViewCalendarEventss = new PropelObjectCollection();
        $this->collViewCalendarEventss->setModel('RcpViewCalendarEvents');
    }

    /**
     * Gets an array of RcpViewCalendarEvents objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this RcpUsers is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|RcpViewCalendarEvents[] List of RcpViewCalendarEvents objects
     * @throws PropelException
     */
    public function getViewCalendarEventss($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collViewCalendarEventssPartial && !$this->isNew();
        if (null === $this->collViewCalendarEventss || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collViewCalendarEventss) {
                // return empty collection
                $this->initViewCalendarEventss();
            } else {
                $collViewCalendarEventss = RcpViewCalendarEventsQuery::create(null, $criteria)
                    ->filterByUsers($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collViewCalendarEventssPartial && count($collViewCalendarEventss)) {
                      $this->initViewCalendarEventss(false);

                      foreach($collViewCalendarEventss as $obj) {
                        if (false == $this->collViewCalendarEventss->contains($obj)) {
                          $this->collViewCalendarEventss->append($obj);
                        }
                      }

                      $this->collViewCalendarEventssPartial = true;
                    }

                    return $collViewCalendarEventss;
                }

                if($partial && $this->collViewCalendarEventss) {
                    foreach($this->collViewCalendarEventss as $obj) {
                        if($obj->isNew()) {
                            $collViewCalendarEventss[] = $obj;
                        }
                    }
                }

                $this->collViewCalendarEventss = $collViewCalendarEventss;
                $this->collViewCalendarEventssPartial = false;
            }
        }

        return $this->collViewCalendarEventss;
    }

    /**
     * Sets a collection of ViewCalendarEvents objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $viewCalendarEventss A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setViewCalendarEventss(PropelCollection $viewCalendarEventss, PropelPDO $con = null)
    {
        $this->viewCalendarEventssScheduledForDeletion = $this->getViewCalendarEventss(new Criteria(), $con)->diff($viewCalendarEventss);

        foreach ($this->viewCalendarEventssScheduledForDeletion as $viewCalendarEventsRemoved) {
            $viewCalendarEventsRemoved->setUsers(null);
        }

        $this->collViewCalendarEventss = null;
        foreach ($viewCalendarEventss as $viewCalendarEvents) {
            $this->addViewCalendarEvents($viewCalendarEvents);
        }

        $this->collViewCalendarEventss = $viewCalendarEventss;
        $this->collViewCalendarEventssPartial = false;
    }

    /**
     * Returns the number of related RcpViewCalendarEvents objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related RcpViewCalendarEvents objects.
     * @throws PropelException
     */
    public function countViewCalendarEventss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collViewCalendarEventssPartial && !$this->isNew();
        if (null === $this->collViewCalendarEventss || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collViewCalendarEventss) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getViewCalendarEventss());
                }
                $query = RcpViewCalendarEventsQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByUsers($this)
                    ->count($con);
            }
        } else {
            return count($this->collViewCalendarEventss);
        }
    }

    /**
     * Method called to associate a RcpViewCalendarEvents object to this object
     * through the RcpViewCalendarEvents foreign key attribute.
     *
     * @param    RcpViewCalendarEvents $l RcpViewCalendarEvents
     * @return RcpUsers The current object (for fluent API support)
     */
    public function addViewCalendarEvents(RcpViewCalendarEvents $l)
    {
        if ($this->collViewCalendarEventss === null) {
            $this->initViewCalendarEventss();
            $this->collViewCalendarEventssPartial = true;
        }
        if (!$this->collViewCalendarEventss->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddViewCalendarEvents($l);
        }

        return $this;
    }

    /**
     * @param	ViewCalendarEvents $viewCalendarEvents The viewCalendarEvents object to add.
     */
    protected function doAddViewCalendarEvents($viewCalendarEvents)
    {
        $this->collViewCalendarEventss[]= $viewCalendarEvents;
        $viewCalendarEvents->setUsers($this);
    }

    /**
     * @param	ViewCalendarEvents $viewCalendarEvents The viewCalendarEvents object to remove.
     */
    public function removeViewCalendarEvents($viewCalendarEvents)
    {
        if ($this->getViewCalendarEventss()->contains($viewCalendarEvents)) {
            $this->collViewCalendarEventss->remove($this->collViewCalendarEventss->search($viewCalendarEvents));
            if (null === $this->viewCalendarEventssScheduledForDeletion) {
                $this->viewCalendarEventssScheduledForDeletion = clone $this->collViewCalendarEventss;
                $this->viewCalendarEventssScheduledForDeletion->clear();
            }
            $this->viewCalendarEventssScheduledForDeletion[]= $viewCalendarEvents;
            $viewCalendarEvents->setUsers(null);
        }
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Users is new, it will return
     * an empty collection; or if this Users has previously
     * been saved, it will retrieve related ViewCalendarEventss from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Users.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|RcpViewCalendarEvents[] List of RcpViewCalendarEvents objects
     */
    public function getViewCalendarEventssJoinEventRequests($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = RcpViewCalendarEventsQuery::create(null, $criteria);
        $query->joinWith('EventRequests', $join_behavior);

        return $this->getViewCalendarEventss($query, $con);
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Users is new, it will return
     * an empty collection; or if this Users has previously
     * been saved, it will retrieve related ViewCalendarEventss from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Users.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|RcpViewCalendarEvents[] List of RcpViewCalendarEvents objects
     */
    public function getViewCalendarEventssJoinEventDefs($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = RcpViewCalendarEventsQuery::create(null, $criteria);
        $query->joinWith('EventDefs', $join_behavior);

        return $this->getViewCalendarEventss($query, $con);
    }

    /**
     * Clears the current object and sets all attributes to their default values
     */
    public function clear()
    {
        $this->id = null;
        $this->ext_id = null;
        $this->position_id = null;
        $this->unit_id = null;
        $this->fname = null;
        $this->lname = null;
        $this->email = null;
        $this->optional_email = null;
        $this->password = null;
        $this->ad_login_1 = null;
        $this->ad_login_2 = null;
        $this->ad_login_3 = null;
        $this->is_superior = null;
        $this->deleted = null;
        $this->active = null;
        $this->last_modified = null;
        $this->created = null;
        $this->alreadyInSave = false;
        $this->alreadyInValidation = false;
        $this->clearAllReferences();
        $this->applyDefaultValues();
        $this->resetModified();
        $this->setNew(true);
        $this->setDeleted(false);
    }

    /**
     * Resets all references to other model objects or collections of model objects.
     *
     * This method is a user-space workaround for PHP's inability to garbage collect
     * objects with circular references (even in PHP 5.3). This is currently necessary
     * when using Propel in certain daemon or large-volumne/high-memory operations.
     *
     * @param boolean $deep Whether to also clear the references on all referrer objects.
     */
    public function clearAllReferences($deep = false)
    {
        if ($deep) {
            if ($this->collLecturePresencess) {
                foreach ($this->collLecturePresencess as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collAuthHistorys) {
                foreach ($this->collAuthHistorys as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collCalendarEventss) {
                foreach ($this->collCalendarEventss as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collEventOrderss) {
                foreach ($this->collEventOrderss as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collLecturess) {
                foreach ($this->collLecturess as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collUserHasLectures) {
                foreach ($this->collUserHasLectures as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collUserRoless) {
                foreach ($this->collUserRoless as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collSystemLogss) {
                foreach ($this->collSystemLogss as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collUserCalendarss) {
                foreach ($this->collUserCalendarss as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collViewCalendarEventss) {
                foreach ($this->collViewCalendarEventss as $o) {
                    $o->clearAllReferences($deep);
                }
            }
        } // if ($deep)

        if ($this->collLecturePresencess instanceof PropelCollection) {
            $this->collLecturePresencess->clearIterator();
        }
        $this->collLecturePresencess = null;
        if ($this->collAuthHistorys instanceof PropelCollection) {
            $this->collAuthHistorys->clearIterator();
        }
        $this->collAuthHistorys = null;
        if ($this->collCalendarEventss instanceof PropelCollection) {
            $this->collCalendarEventss->clearIterator();
        }
        $this->collCalendarEventss = null;
        if ($this->collEventOrderss instanceof PropelCollection) {
            $this->collEventOrderss->clearIterator();
        }
        $this->collEventOrderss = null;
        if ($this->collLecturess instanceof PropelCollection) {
            $this->collLecturess->clearIterator();
        }
        $this->collLecturess = null;
        if ($this->collUserHasLectures instanceof PropelCollection) {
            $this->collUserHasLectures->clearIterator();
        }
        $this->collUserHasLectures = null;
        if ($this->collUserRoless instanceof PropelCollection) {
            $this->collUserRoless->clearIterator();
        }
        $this->collUserRoless = null;
        if ($this->collSystemLogss instanceof PropelCollection) {
            $this->collSystemLogss->clearIterator();
        }
        $this->collSystemLogss = null;
        if ($this->collUserCalendarss instanceof PropelCollection) {
            $this->collUserCalendarss->clearIterator();
        }
        $this->collUserCalendarss = null;
        if ($this->collViewCalendarEventss instanceof PropelCollection) {
            $this->collViewCalendarEventss->clearIterator();
        }
        $this->collViewCalendarEventss = null;
        $this->aUnits = null;
        $this->aPositions = null;
    }

    /**
     * return the string representation of this object
     *
     * @return string
     */
    public function __toString()
    {
        return (string) $this->exportTo(RcpUsersPeer::DEFAULT_STRING_FORMAT);
    }

    /**
     * return true is the object is in saving state
     *
     * @return boolean
     */
    public function isAlreadyInSave()
    {
        return $this->alreadyInSave;
    }

}
